为什么不自动处理接口配置中用于路由的两个 post-up 命令中的第一个

Chr*_*sZZ 5 networking iptables

我们设法将我们的服务器连接到两个不同的网络,一切正常。我们使用路由规则来确保服务器响应正确的网络。

我按照此链接下的说明进行操作:http : //www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System#Configuring_the_New_Routing_Table

现在遇到如下问题: 二、重启服务器,只建立了一个路由配置(rt3)。只有第二组后期命令似乎可以自动工作。

我可以轻松解决这个问题,购买然后手动执行第一组后期命令 (rt2),一切都会按预期工作。

但当然,后期命令应该自动执行。

这是我们的接口文件:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
allow-hotplug eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
broadcast xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
dns-nameservers xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 4.2.2.2 8.8.4.4
post-up ip route add xxx.xxx.xxx.xxx/24 dev eth0 src xxx.xxx.xxx.xxx table rt2
post-up ip route add default via xxx.xxx.xxx.xxx dev eth0 table rt2
post-up ip rule add from xxx.xxx.xxx.xxx/32 table rt2
post-up ip rule add to xxx.xxx.xxx.xxx/32 table rt2

# The secondary network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
broadcast xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
dns-nameservers xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 4.2.2.2 8.8.4.4
post-up ip route add xxx.xxx.xxx.xxx/24 dev eth1 src xxx.xxx.xxx.xxx table rt3
post-up ip route add default via xxx.xxx.xxx.xxx dev eth1 table rt3
post-up ip rule add from xxx.xxx.xxx.xxx/32 table rt3
post-up ip rule add to xxx.xxx.xxx.xxx/32 table rt3
Run Code Online (Sandbox Code Playgroud)

手动执行 rt2 的命令后,一切都很完美,我们让这个配置运行了数周没有任何问题。

rt_tables 文件如下:

#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
1 rt2
2 rt3
Run Code Online (Sandbox Code Playgroud)