Adding persistent static routes on centos

Centos Network

When you need to access networks located on a different network segment, you need to have a route set up so the PC knows how to get to the other network segment. This generally just points to your main gateway, but you may want to set up additional static routes, where you don’t want the traffic going through your main default gateway.

To set up a static route on CentOS so that it automatically gets created every time the PC starts, you need to create a ‘route-<interface>‘ file in the ‘/etc/sysconfig/network-scripts’ folder.

Use your favorite text editor and edit/create the route-<interface> file.


The route will get set up when the specified interfaces comes up.

This file will probably wont exist if you don’t have any existing static routes.

Add a line with the route information in the following format to the file.


Modify the above to suit the route you want to add. If you take off the “dev eth0″ part it will automatically determine which interface to use at the time.

To make these changes take effect, you can run the following command to bring down the interface, and bring it back up again:

Take down the eth0 interface, and bring it back up:



Restart all network interfaces:

or simply try a reboot.

Run the following command to ensure the route has been set up correctly: