Thursday, January 5, 2012

Add static route to linux

add a remote host

remote host 192.168.1.20
local gateway 10.1.1.20
route add -host 192.168.1.20 gw 10.1.1.20

add a remote network

route add -net 192.168.98.42 netmask 255.255.255.255 gw 192.168.99.1
 
check the route 
route -n
 
Delete a route
route del -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8
 
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the network 192.56.76.x via "eth0". The Class C netmask modifier is not really necessary here because 192.* is a Class C IP address. The word "dev" can be omitted here.
 
To make the routing information persistent, add the “route add” line as seen above into the /etc/rc.local file.
Sample /etc/rc.local file.
or /etc/rc.d/rc.local

touch /var/lock/subsys/local
route add -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8



 


  
 

No comments:

Post a Comment