I have services running on VPS A(184.108.40.206) on ports 30000-32000.
I would like to have VPS B(220.127.116.11) to port forward them to 20000- 22000.
(You may take a look at the demo graph link below to understand what I would like to achieve :D )
I used the command below to set up iptables:
iptables -t nat -A PREROUTING -p tcp --dport 20000:22000 -j DNAT --to-destination 18.104.22.168:30000-32000 iptables -t nat -A POSTROUTING -p tcp -d 22.214.171.124 --dport 30000:32000 -j SNAT --to-source 126.96.36.199 20000:22000 iptables -t nat -A PREROUTING -p udp --dport 20000:22000 -j DNAT --to-destination 188.8.131.52:30000-32000 iptables -t nat -A POSTROUTING -p udp -d 184.108.40.206 --dport 30000:32000 -j SNAT --to-source 220.127.116.11 20000:22000
After some tests, I find that it seems that only port 20000 was forwarding the original server's port 30000. However, other ports are not working.
I checked 4 things below: 1. VPS A (18.104.22.168)'s service Service running on ports 30000 - 32000 are fully functional
- VPS B port forwarding setting Upon checking sysctl on VPS B, ipv4 forwarding is enabled.
net.ipv4.ip_forward = 1)
- VPS B's iptable setting. It looks fine to me. You may click on the link below for exact setting.
- I also tried to do a normal multiple port forwarding from VPS A to VPS B (i.e. VPS A (30000-32000) >> VPS B (30000-32000))
(You may take a look at the demo graph link below for what I would like to achieve :D )
Everything is working fine.
I really have no idea how to achieve it. Any help is appreciated! Thank you in advance!