Jan 25, 2018

Add Persistence Static Routes

To add permanent Static route, edit file /etc/sysconfig/network-scripts/route-eth0 (eth0 is the device name) and add the following lines and save and exist. 


By default route-eth0 file will not be there, need to be created.

For RHEL/CentOS/Fedora

$ sudo vim /etc/sysconfig/network-scripts/route-eth0
10.10.20.0/24 via 192.168.50.100 dev eth0

For Ubuntu/Debian/Linux Mint

Open the file /etc/network/interfaces and at the end add the persistence Static routes. IP Addresses may differ in your environment.
$ sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.50.2
netmask 255.255.255.0
gateway 192.168.50.100
#########{Static Route}###########
up ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0
Next, restart network services after entering all the details using the following command.
# /etc/init.d/network restart
$ sudo /etc/init.d/network restart


For Ubuntu:

Restart Ubuntu server networking service