如何在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
~ # routedeldefault
~ # 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 ~]#