Three Ways to Configure Persistent Static Routes on Linux CentOS

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 :

[root@centos63 ~]# 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 :


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

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

any -net netmask gw
any -net netmask gw

How to Change The Default Route or Gateway on Solaris

In this post, i will show you on how to change the default gateway of the Solaris server. The configuration will take effect immediately without rebooting and also will apply after the next reboot. This is the most preferable plan since it will avoid any network interruption.

Steps :
1. Edit /etc/defaultrouter
-This configuration will apply after next reboot.

[root@SolarisServer ~]# vi /etc/defaultrouter

Proceed to change the ip to your preferred/new ip address of your gateway and save.

2. Run the following command to delete and add the default route.
-This will apply the configuration with immediate effect. Assume that the existing gateway will be change to

[root@SolarisServer ~]# route delete default
[root@SolarisServer ~]# route add default