Wednesday 17 October 2012

How to add route in Linux



1.To view the current routing table run “route -n” 
2.To add a route refer to the command below.
   "route add -net 10.41.41.0 netmask 255.255.255.0 gw    10.41.42.8"

3.To delete a route refer to the command below.
"route del -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8"

4.The routing information above is not persistent across reboots. After a reboot, the routing information will be lost and you need to add them in again.
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.
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
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