一台服务器有三块网卡,上面运行三个服务,如何让每个服务只用一张网卡?
在一台服务器上用 docker 跑了三个服务,A 服务端口 500、B 服务端口 600、C 服务端口 700 ; 这台服务器有三张网卡,都有固定的公网 IP ; 现在需求是使用同一个端口去访问这三个公网 IP,实现 IP1 访问到 A:500,IP2 访问到 B:600,IP3 访问到 C:700 ; 我写了下面的 iptables 规则还是没法访问,各位老哥问题出在哪儿?
iptables -t nat -I PREROUTING -i eth1 -p udp --dport 80 -j DNAT --to-destination 127.0.0.1:500
iptables -t nat -I PREROUTING -i eth2 -p udp --dport 80 -j DNAT --to-destination 127.0.0.1:600
iptables -t nat -I PREROUTING -i eth3 -p udp --dport 80 -j DNAT --to-destination 127.0.0.1:700
iptables -t nat -A POSTROUTING -p udp -d 127.0.0.1 --dport 500 -j SNAT --to-source 1.1.1.1
iptables -t nat -A POSTROUTING -p udp -d 127.0.0.1 --dport 600 -j SNAT --to-source 2.2.2.2
iptables -t nat -A POSTROUTING -p udp -d 127.0.0.1 --dport 700 -j SNAT --to-source 3.3.3.3
本文由 vps网友提供,转载请注明出处
本文链接: https://www.vpsvsvps.com/discuss/a/1676471983505674240.html