How to Configure Persistent Static Routes on Linux CentOS 6.2

Share this Article :

In this post, i will share on how to configure persistent static routes on linux CentOS 6.2 server. By using Static routes, we can improves overall performance of the network. Static route can be added and delete using “route” command. But the drawback is when linux server is rebooted, it will forget the static routes configuration. To avoid network interruption the following condition should be follow :

1. The static route configuration should take effect immediately without rebooting.
2. The static route configuration should also apply after the next reboot.

Solutions :
To make configuration take effect immediately, run the following command :

[[email protected] ~]# route add -net <network> netmask <netmask> gw <gateway_ip> dev <interface>

Examples :

[[email protected] ~]# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0
[[email protected] ~]# route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1 dev eth1
[[email protected] ~]# route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1 dev eth2

To apply the configuration on next reboot, configure the following in /etc/sysconfig/static-routes :

[[email protected] ~]# vi /etc/sysconfig/static-routes

Add the followings :

any -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
any -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1
any -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1

Leave a Reply