我的服务在端口 30000-32000 上的 VPS A(1.1.1.1) 上运行。
我想要 VPS B(2.2.2.2) 将它们端口转发到 20000-22000。
(您可以查看下面的演示图链接以了解我想要实现的目标:D)
我使用下面的命令来设置 iptables:
iptables -t nat -A PREROUTING -p tcp --dport 20000:22000 -j DNAT --to-destination 1.1.1.1:30000-32000
iptables -t nat -A POSTROUTING -p tcp -d 1.1.1.1 --dport 30000:32000 -j SNAT --to-source 2.2.2.2
20000:22000
iptables -t nat -A PREROUTING -p udp --dport 20000:22000 -j DNAT --to-destination 1.1.1.1:30000-32000
iptables -t nat -A POSTROUTING -p udp -d 1.1.1.1 --dport 30000:32000 -j SNAT --to-source 2.2.2.2
20000:22000
Run Code Online (Sandbox Code Playgroud)
经过一些测试,我发现似乎只有20000端口转发了原服务器的30000端口。但是其他端口都不起作用。
我检查了以下 4 件事: 1. VPS A …