有台双网卡的 centos 。 eth0 的外网 IP 为:35.68.21.210 ,内网 IP 为:172.31.11.120 ; eth1 的外网 IP 为:3.112.105.71 ,内网 IP 为:172.31.6.9 。网关都是 172.31.0.1 (慎重考虑起见,真实外网 IP 不是所写的)
默认路由的问题,用策略路由指定 eth1 的 IP 走另一个路由表就行了 ip rule add from 3.112.105.71 lookup 100 ip route add default gw 172.31.0.1 dev eth1 table 100
360750581
2022-03-04 09:51:20 +08:00
为啥一定要用 iptables ,换个思路,nginx 反代不是完美实现
aboutboy
2022-03-06 21:13:30 +08:00
@bearice 感觉你这个方法是正确的思路。 不过我在执行 ip route add default gw 172.31.0.1 dev eth1 table 100 时,提示错误: Error: either "to" is duplicate, or "gw" is a garbage. 现在还是不能实现两张网卡同时 nat