If I have two Virtual Private Servers and they are located in different countries. Then I want to use one server (18.104.22.168) as a proxy server to proxy tcp and udp traffic, the proxy process listens on local port 8300. Another server (22.214.171.124) will be used to relay the traffic to the proxy server.
Someone taught me how to achieve this by using IPTABLES:
STEP 1: set up the proxy program on the proxy server (126.96.36.199) and run it
STEP 2: write a few iptables rules on the relay server (188.8.131.52), like this:
iptables -t nat -A PREROUTING -p tcp --dport 8300 -j DNAT --to-destination 184.108.40.206:8300 iptables -t nat -A PREROUTING -p udp --dport 8300 -j DNAT --to-destination 220.127.116.11:8300 iptables -t nat -A POSTROUTING -d 18.104.22.168 -p tcp --dport 8300 -j SNAT --to-source 22.214.171.124 iptables -t nat -A POSTROUTING -d 126.96.36.199 -p udp --dport 8300 -j SNAT --to-source 188.8.131.52
STEP 3: set up the proxy client program to make all tcp and udp traffic go to the relay server
But I am confused about this method. For example, I am playing a online game that use udp or tcp to communicate with the game server. When these traffic arrive the relay server, they will be DNATed and finally arrive the proxy server, but can the proxy server know where these traffic be sent to? I mean will the proxy server send these traffic to the game server? If it will, how can the proxy server know the real game server address after the destination address of the traffic has already been changed on the relay server?