码迷,mamicode.com
首页 > 其他好文 > 详细

添加路由条目(永久)

时间:2015-04-15 23:32:34      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:route-eth0

方法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

添加路由条目(永久)

标签:route-eth0

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!