Three Ways to Configure Persistent Static Routes on Linux CentOS

Share this Article :

centos6There are several different ways to configure persistent static routes on Linux CentOS. By using Static routes, we can improves overall performance of the network and static routing is achieved by manually adding routes to the routing table. Static route can be added and delete using “route” command. But it will forget the static routes configuration when server rebooted. This will lead to the network interruption. Follow one of these three options to configure static route on CentOS.

1. Edit the file /etc/sysconfig/network-scripts/route- and then add the following lines :

[[email protected] ~]# vi /etc/sysconfig/network-scripts/route-eth0

GATEWAY0=<gateway address>
NETMASK0=<network netmask>
ADDRESS0=<network address>
GATEWAY1=<gateway address>
NETMASK1=<network netmask>
ADDRESS1=<network address>

Examples :

GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.1.54
GATEWAY1=192.168.2.1
NETMASK1=255.255.255.0
ADDRESS1=192.168.2.54

2. Edit the file /etc/sysconfig/network-scripts/route- and then add the following lines :

192.168.1.0/24 via 192.168.1.1 dev eth0
192.168.2.0/24 via 192.168.2.1 dev eth0

3. Edit the file /etc/sysconfig/static-routes as below :

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

Leave a Reply