如何修复 eth0 和 eth1(通过 eth0 流出的流量失败)?

如何修复 eth0 和 eth1(通过 eth0 流出的流量失败)?

我有两个公共IP。一个连接到 eth0,一个连接到 eth1,从 2 个独立的路由器作为完整的 DMZ 到 LAN IP。

我添加了以下内容:

ip rule add from 10.0.0.108/32 table 1 # outbound
ip rule add to 10.0.0.108/32 table 1   # inbound
ip route add default via 10.0.0.1 dev eth0 table 1
ip rule add from 10.0.0.100/32 table 2 # outbound
ip rule add to 10.0.0.100/32 table 2   # inbound
ip route add default via 10.0.0.1 dev eth1 table 2

自从添加上面的内容以来,我在正确发送入站和出站流量时遇到了问题。

例如:

$ ping -I eth0 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 10.0.0.108 eth0: 56(84) bytes of data.
From 10.0.0.108 icmp_seq=2 Destination Host Unreachable
From 10.0.0.108 icmp_seq=3 Destination Host Unreachable
From 10.0.0.108 icmp_seq=4 Destination Host Unreachable

$ ping -I eth1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 10.0.0.28 eth1: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=48 time=14.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=48 time=14.6 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1233ms
rtt min/avg/max/mdev = 14.611/14.639/14.667/0.028 ms

如何使用ip rule add from/to方法修复 eth0(从/到),但不破坏 eth1(eth1 工作完美)。

答案1

看来您正在通过 eth1 路由所有流量(default via 10.0.0.1 dev eth1 table 2优于eth1 default via 10.0.0.1 dev eth0 table 1),但仅使用数据包的-I eth0替换(如果我不正确,请纠正我)。另外,两个网络中都存在网关吗?src IPicmp10.0.0.1

我相信这篇 LARTC 文章绝对应该对你有帮助。顺便说一句,如果您向我们提供更多网络配置详细信息,那就太好了。

相关内容