Linux Ubuntu:重置默认路由表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16411625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ubuntu: Reset default routing table
提问by Winston
On my computer I have 2 connections - 3G and LAN.
在我的电脑上,我有 2 个连接 - 3G 和 LAN。
Before the 3G is connected the routing table would look like this:
在连接 3G 之前,路由表如下所示:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 100 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
After the 3G dialup the routing table would look like this:
3G拨号后路由表如下所示:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.64.64.64 0.0.0.0 UG 0 0 0 ppp0
10.64.64.64 * 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
After the 3G is being disconnected, the routing table would look like this:
3G断开后,路由表如下所示:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
Since the default routing is disabled after the 3G is being disconnected, there is no way for the system to connect to the server, even the LAN is active.
由于3G断开后默认路由被禁用,系统无法连接到服务器,即使局域网处于活动状态。
Is there a way I can modify the routing table after the 3G is being disconnected?
3G断线后有没有办法修改路由表?
Thanks in advance
提前致谢
采纳答案by Guy Hillyer
% sudo route add default gw 192.168.0.1
% sudo route 添加默认 gw 192.168.0.1
If the route command is not available, try
如果路由命令不可用,请尝试
% sudo ip route add default via 192.168.0.1
% sudo ip route 通过 192.168.0.1 添加默认值