Static route modification command under CentOS
Method One:
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 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 default route
Route add default GW 192.168.0.1
Default route one is enough.
Route-n Viewing the routing table
Method Two:
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 Add route
del Delete route
Via Gateway egress IP Address
Dev Gateway Export Physical device name
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
IP route
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
CentOS Add route table