Persistent route (static, but not a default route)

Say, you have route like this:

route add -net 192.168.210.0/24 192.168.1.3 dev eth1

And you want to make it persistent (and oviously static)  – so it would load every time on bootup, you should create a file in /etc/sysconfig/network-scripts named route-eth1:

vi /etc/sysconfig/network-scripts/route-eth1

and add

192.168.210.0/24 via 192.168.1.3

The file itself will thell Centos that you want to route for eth1, and the rest is easy to understand. If the interface is not eth1 then change the file name accordingly – adapt this to You appliance, then reboot the machine (sometimes reloading the network services with service network reload works, but sometimes the box just hangs there), and you should be good to go.

Persistent default route

If you want to make a persistent default route (obviously, you can have only one, and it will be your gateway), you should edit the /etc/sysconfig/network file:

vi /etc/sysconfig/network
gateway=<your_default_route_ip>

and save.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.