首页 > 其他 > 详细

添加路由条目(永久)

时间:2015-04-15 23:29:46      阅读:251      评论:0      收藏:0      [点我收藏+]

方法1:echo "192.168.1.0/24 via 172.17.100.1" > /etc/sysconfig/network-scripts/route-eth0

[root@cms ~]# echo "192.168.1.0/24 via 172.17.100.1" > /etc/sysconfig/network-scripts/route-eth0
[root@cms ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     172.17.100.1    255.255.255.0   UG    0      0        0 eth0
172.17.100.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         172.17.100.1    0.0.0.0         UG    0      0        0 eth0
[root@cms ~]#


方法2:

[root@cms ~]# echo -e "ADDRESS0=192.168.1.0\nNETMASK0=255.255.255.0\nGATEWAY0=172.17.100.1" > /etc/sysconfig/network-scripts/route-eth0
[root@cms ~]# cat /etc/sysconfig/network-scripts/route-eth0
ADDRESS0=192.168.1.0
NETMASK0=255.255.255.0
GATEWAY0=172.17.100.1
[root@cms ~]# /etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Determining if ip address 172.17.100.240 is already in use for device eth0...
                                                           [  OK  ]
[root@cms ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     172.17.100.1    255.255.255.0   UG    0      0        0 eth0
172.17.100.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         172.17.100.1    0.0.0.0         UG    0      0        0 eth0
[root@cms ~]#

 




本文出自 “HeZhang” 博客,请务必保留此出处http://hezhang.blog.51cto.com/1347601/1633122

添加路由条目(永久)

原文:http://hezhang.blog.51cto.com/1347601/1633122

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!