Route manipulates the kernel’s IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig program. |
When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables. |
Add static route using “route add”: |
# route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0 |
If you want persistent static route, you need to edit /etc/sysconfig/network-scripts/route-eth0file to define static routes for eth0 interface. |
# vim /etc/sysconfig/network-scripts/route-eth0 |
GATEWAY0=192.168.1.1 |
NETMASK0=255.255.255.0 |
ADDRESS0=192.168.100.0 |
Save and close the file. Restart networking: |
# service network restart |
Verify new routing table by, |
# route –n or # netstat –nr |
Friday, May 20, 2016
route add in Linux
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment