如何更改默认路由以使用 eth1 (DHCP) 而不是 eth0(静态)?我希望这是通过重新启动而持久的永久解决方案。
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default RT-C0C1C0CF879F 0.0.0.0 UG 100 0 0 eth0
10.0.0.0 * 255.255.255.0 U 0 0 0 eth0
1.1.1.0 * 255.255.240.0 U 0 0 0 eth1
Run Code Online (Sandbox Code Playgroud)
我希望直接路由 (eth1) 为默认路由,而不是通过 NAT。
使用 Ubuntu 12.04
Jon*_*eig 12
我在以下位置找到了答案:http : //xmodulo.com/2012/03/how-to-set-default-route-in-linux.html
利用 /etc/network/interfaces 中的 post-up 命令删除任何不必要的默认路由,如下所示。这将通过 eth0 启用默认路由
$ sudo vi /etc/network/interfaces
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug eth1
iface eth1 inet dhcp
post-up route del default dev $IFACE
Run Code Online (Sandbox Code Playgroud)