Debian Jessie / etc / network / interfaces后续路由网关不会坚持重启

我有一个有2个接口的Debian Jessie盒子。 我希望eth1在公共静态IP 1.2.3.4上路由公共stream量,eth0在192.168.0.55上路由mgmtstream量,所以我编辑/ etc / network / interfaces看起来像这样:

source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth1 iface eth1 inet static address 1.2.3.4 netmask 255.255.255.0 gateway 1.2.3.1 dns-nameservers 8.8.8.8 post-up route del default gw 192.168.0.1 eth0 post-up route add default gw 1.2.3.1 eth1 # The primary network interface allow-hotplug eth0 iface eth0 inet static address 192.168.0.55 netmask 255.255.255.0 gateway 192.168.0.1 

但是当我重新启动时,我必须手动删除192.168.0.1 eth0网关并添加1.2.3.1 eth1之一。 为什么这不会在重新启动后持续? 还有其他地方设置了默认路由/ gw吗?

您有两个不同的网关configuration为两个接口,这是永远不会按照你想要的方式工作。 如果您只需要一个默认网关,则还需要configuration一个。 您不需要局域网(192.168.0.0/24)的网关进行内部通信。 如果您启用了ip_forward,则lan计算机将可以上网。

尝试这个:

的/ etc /networking/接口

 source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth0 iface eth0 inet static address 192.168.0.55 netmask 255.255.255.0 # The secondary network interface allow-hotplug eth1 iface eth1 inet static address 1.2.3.4 netmask 255.255.255.0 gateway 1.2.3.1 dns-nameservers 8.8.8.8 

我想,eth1会在eth0和脚本试图删除不存在的路由之前启动。

尝试这个:

 source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth1 allow-hotplug eth1 iface eth1 inet static address 1.2.3.4 netmask 255.255.255.0 gateway 1.2.3.1 dns-nameservers 8.8.8.8 post-up ifup eth0 post-up route del default gw 192.168.0.1 eth0 post-up route add default gw 1.2.3.1 eth1 # The primary network interface allow-hotplug eth0 iface eth0 inet static address 192.168.0.55 netmask 255.255.255.0 gateway 192.168.0.1