1. Method One:
- Add Add route
- del Delete route
- -net setting a route to a network segment
- -host setting a route to a host
- GW Export Gateway IP address
- Dev Egress Gateway Physical device name
- Add route
- Route add-net 192.168.0.0/24 GW 192.168.0.1
- Route Add-host 192.168.1.1 Dev 192.168.0.1
- Delete route
- Route del-net 192.168.0.0/24 GW 192.168.0.1
- Add default route
- Route add default GW 192.168.0.1
- Route-n Viewing the routing table
Method Two:
- Add Add route
- del Delete route
- Via Gateway egress IP Address
- Dev Gateway Export Physical device name
- Add route
- IP route add 192.168.0.0/24 via 192.168.0.1
- IP route add 192.168.1.1 dev 192.168.0.1
- Delete route
- IP route del 192.168.0.0/24 via 192.168.0.1
- Add default route
- IP route add default via 192.168.0.1 dev eth0
- Via 192.168.0.1 is my default router
- Viewing routing information
- Save the routing settings so that they are valid after a network restart
- Create a file named Route-eth0 under the/etc/sysconfig/network-script/directory
- Vi/etc/sysconfig/network-script/route-eth0
- Add content in this file in the following format
- 192.168.1.0/24 via 192.168.0.1
- Restart network authentication
There are a few lines in/etc/rc.d/init.d/network:
# Add non interface-specific static-routes.
if [-f/etc/sysconfig/static-routes]; Then
grep "^any"/etc/sysconfig/static-routes | While read ignore args; Do
/sbin/route add-$args
Done
Fi
In other words, adding static routes to the/etc/sysconfig/static-routes file is OK.
If you join:
Route add-net 11.1.1.0 netmask 255.255.255.0 GW 11.1.1.1
The format of the static-routes is
Any net 11.1.1.0 netmask 255.255.255.0 GW 11.1.1.1
Linux Static route modification