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

创建静态路由

时间:2017-03-09 16:04:29      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:静态路由

route -n -v
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.40.0       0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         10.0.40.1       0.0.0.0         UG    0      0        0 eth0


route add -v a.b.c.d  gw 10.0.40.17


route -n -v
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
198.35.28.125   10.0.40.17      255.255.255.255 UGH   0      0        0 eth0
10.0.40.0       0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         10.0.40.1       0.0.0.0         UG    0      0        0 eth0



if we need to delete the static route, here is the command:

delete static route to destination ip a.b.c.d
route del a.b.c.d



the ‘route add‘ command is obsolete, the new command is ‘ip route add‘

ip route add a.b.c.d via 10.0.40.17 dev eth0  # add a static route
ip route del   a.b.c.d            # delete a static route

the ‘ip route add‘ command and ‘route add‘ command are temporary, meaning the entries will be gone after reboot. to make it permanent.   Edit the file /etc/sysconfig/entwork-scripts/route-eth0

cat /etc/sysconfig/network-scripts/route-eth0
a.b.c.d via 10.0.40.17 dev eth0
  • to manually reload the route-eth0 file, simply restart the network service
    service network restart




本文出自 “小V运维之路” 博客,请务必保留此出处http://victor2016.blog.51cto.com/6768693/1904632

创建静态路由

标签:静态路由

原文地址:http://victor2016.blog.51cto.com/6768693/1904632

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