Add Persistent Static Routes

To add permanent Static route

For RHEL/CentOS/Fedora

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.
$ 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

If it is managed by NetworkManager, you can use nmtui to add the static route.



$ sudo systemctl restart NetworkManager


For Ubuntu:

Restart Ubuntu server networking service

Popular posts from this blog

How to get Active Transactions and Locks from MySQL

Example of a PAC file