是否可以在主路由表中没有默认网关条目的情况下建立出站流量

是否可以在主路由表中没有默认网关条目的情况下建立出站流量

我在 /etc/iproute2/rt_tables 中为 eth0 接口添加了一个特定路由表,表名为 eth0-rt。但是,出站流量无法从机箱中运行。将默认网关条目添加到主路由表后,流量似乎运行正常,而当网关从主表中删除时,流量停止运行。除了在自定义的出站流量路由表中添加默认网关条目外,是否必须在主路由表中添加默认网关条目?

详细说明

我正在使用 busy box v31.1。其中有两个接口,即 eth0 和 eth1。在 /etc/iproute2/rt_tables 中添加这些条目后,我为每个接口实现了不同的路由表,即 eth0-rt 和 eth1-rt。这些是我添加的 ip 路由和规则命令

ifconfig eth0 10.184.194.108 网络掩码 255.255.255.0 广播 10.184.194.255 mtu 1500 启动 ifconfig eth0 hw ether aa:bb:cc:dd:11:aa ip route add 10.184.194.0/24 dev eth0 src 10.184.194.108 table eth0-rt ip route add default via 10.184.194.1 dev eth0 table eth0-rt ip rule add from 10.184.194.108/32 table eth0-rt ip rule add to 10.184.194.108/32 table eth0-rt

ifconfig eth1 10.184.194.109 网络掩码 255.255.255.0 广播 10.184.194.255 mtu 400 启动 ifconfig eth1 hw ether aa:bb:cc:dd:11:bb ip route add 10.184.194.0/24 dev eth1 src 10.184.194.108 table eth1-rt ip route add default via 10.184.194.1 dev eth1 table eth1-rt ip rule add from 10.184.194.109/32 table eth1-rt ip rule add to 10.184.194.109/32 table eth1-rt

添加这些后,“主”路由表中没有默认网关条目,但 eth0-rt 和 eth1-rt 路由表中有默认条目。通过这些 IP 地址的入站流量运行良好。但到互联网的出站流量不起作用。是不是因为我在主路由表中没有默认网关条目。主路由表中是否也有必要有这些默认条目?

你好

我添加了以下 IP 规则:

ip rule add from 10.184.194.108/32 table eth0-rt
ip rule add to 10.184.194.108/32 table eth0-rt

但是出站流量不起作用。但是当我添加以下规则时

ip rule add from all table eth0-rt

它可以工作。但是我无法继续执行此规则,因为我有另一个接口 eth1,当连接到不同的网络时,也可以连接该接口以建立互联网连接。当使用两个接口建立互联网连接时,是否始终需要首选项?我希望接口灵活,因此我分别在每个表中创建了两个不同的路由表和两个默认网关,并且这两个接口都尝试从两个网络访问互联网。没有首选项可以实现吗?请帮忙

相关内容