How to add static routes under RedHat os

To add static routing in RHEL system we need to edit/create file for chosen interface:

vi /etc/sysconfig/network-scripts/route-bond0

we put in it information to which network we need redirection, mask and gateway eg.:

10.20.20.0/24 via 10.10.10.1
10.30.30.0/24 via 10.10.10.1

then we refresh routes using command:

/etc/sysconfig/network-scripts/ifup-routes bond0

Other option (which works in most linux-based systems)  is add commands to file /etc/local:

vi /etc/rc.local

route add -net 10.20.20.0 netmask 255.255.255.0 gw 10.10.10.1 dev eth1
route add -net 10.30.30.0 netmask 255.255.255.0 gw 10.10.10.1 dev eth1

Leave a Response