Static routes will be added usually through “route add” or “ip route” command.
example:
route add -net DESTINATIONip netmask NETMASKip gw GATEWAYip dev ethX
route add -net DESTINATIONip netmask NETMASKip gw GATEWAYip dev ethX
So to add a specific route of 113.121.192.219 out gateway 10.128.216.129 via interface ETH1:
route add -net 113.121.192.219 netmask 255.255.255.255 gw 10.128.216.129 dev eth1
To make it persistent, add it to /etc/sysconfig/network-scripts/route-ethX
Adding Persistent static route:
MAKE SURE YOU HAVE THE SYNTAX EXACTLY RIGHT, ELSE IT WILL FAIL
CAPITALS!
CAPITALS!
You can have multiple ones of course, you just increment the value. There is no space, follow the example below. This one shows adding 3 different static routes.
GATEWAY0=10.1.100.1
NETMASK0=255.255.0.0
ADDRESS0=10.1.0.0
GATEWAY1=10.1.100.1
NETMASK1=255.255.0.0
ADDRESS1=10.2.0.0
GATEWAY2=10.1.100.1
NETMASK2=255.255.0.0
ADDRESS2=10.3.0.0
GATEWAY3=10.1.100.1
NETMASK3=255.255.0.0
ADDRESS3=10.4.0.0
Save and close the file and restart networking. Reboot to prove!
Nice share thanks for posting
ReplyDelete