Add route
Del delete route
-Net
-Host: set the route to a host.
Gw egress gateway IP address
Dev egress gateway physical device name
Add default route
Route add default gw 192.168.0.1
By default, one route is enough.
Route-n View route table
Method 2:
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 a route
Ip route del 192.168.0.0/24 via 192.168.0.1
Add route
Del delete route
Via gateway egress IP address
Dev gateway egress 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
View route information
Ip route
Save route settings so that they are valid after network restart
Create a file named route-eth0 in the/etc/sysconfig/network-script/directory.
Vi/etc/sysconfig/network-script/route-eth0
Add the following content to this file:
192.168.1.0/24 via 192.168.0.1
Restart network verification
/Etc/rc. d/init. d/network contains the following lines:
# 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
That is, add the static route to the/etc/sysconfig/static-routes file.
For example, join:
Route add-net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1
The static-routes format is
Any net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.