如何在linux命令行下修改默认路由
1.删除默认网关
~ # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.129.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.129.17 0.0.0.0 UG 0 0 0 eth0
~ # route del default
~ # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.129.0 * 255.255.255.0 U 0 0 0 eth0
2.添加默认网关
~ # route add -net 0.0.0.0 gw 192.168.129.254
~ # route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.129.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
default 192.168.129.254 0.0.0.0 UG 0 0 0 eth0
~ #
附:route add命令参数
[root@iVS-VM8000-Server ~]# route add
Usage: inet_route [-vF] del {-host|-net} Target[/prefix] [gw Gw] [metric M] [[dev] If]
inet_route [-vF] add {-host|-net} Target[/prefix] [gw Gw] [metric M]
[netmask N] [mss Mss] [window W] [irtt I]
[mod] [dyn] [reinstate] [[dev] If]
inet_route [-vF] add {-host|-net} Target[/prefix] [metric M] reject
inet_route [-FC] flush NOT supported
[root@iVS-VM8000-Server ~]#
该案例暂时没有网友评论
✖
案例意见反馈
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作