Question & Answer
Question
When you want to add a static route permanently on the host, you need to add it to a file so that it takes effect after OS reboots.
Answer
You need to add the static configuration to a file "route-XXX" under /etc/sysconfig/network-scripts/ directory. XXX is the network interface name that you add the static route to.
For example, if you want to add the following static route permanently
/sbin/route add -net 10.20.30.0 netmask 255.255.225.0 gw 123.4.5.6 bond1
You want to create the following file (if not exist),
/etc/sysconfig/network-scripts/route-bond1
and add the following
ex)
GATEWAY1=123.4.5.6
ADDRESS1=10.20.30.0
NETMASK1=255.255.225.0
If the file already exists and has some static routes, you need to change the number after the GATEWAY#, ADDRESS# and NETMASK# so that it does not become duplicate.
For example, if there are two existing static route in the file, you need to change the number to 3:
ex)
GATEWAY3=123.4.5.6
ADDRESS3=10.20.30.0
NETMASK3=255.255.225.0
.
Was this topic helpful?
Document Information
Modified date:
17 October 2019
UID
swg21698754