There is more than one way to add static routes on Centos. One way is to just use ip route or route commands as we shall see. On the other hand if we want those routes to persist after reboot then we need to use nmcli or do it the old fashion way and edit some config files. We shall see both ways below as we::

Add persistent routes

By using nmcli command line tool

On Centos 7 onwards and already many versions of Fedora, using nmcli is the preferred way of adding persistent route.

nmcli connection modify "connection-name" +ipv4.routes "network address/prefix gateway"

nmcli connection up "connection-name"

We can verify:

nmcli connection show

For example, lets add an entry that will route all traffic to the network through the gateway of And the name of the connection is enp0s3.

nmcli connection modify "enp0s3" +ipv4.routes ""

nmcli connection reload

nmcli connection up enp0s3

Do not Forget the + mark before the keyword ipv4.routes (+ipv4.routes). Otherwise, existing entries will be overridden.

Method Two : Manually Create Configuration File
It is also possible to add permanent IP routes directly into the configuration file. First, we need to create the configuration file inside the /etc/sysconfig/network-scripts/ directory using the following format.


For example, if the name of the network connection is enp0s3, then The name of the configuration file should be


Next Insert the routing to the configuration file using following format. via via via

Alternatively, you can also use the following format.







Finally, you need to restart the network connection using nmcli command.

nmcli connection reload

nmcli connection up enp0s3

You can use the either of these two methods to add permanent routes in CentOS 7 Linux.