I have two Linux servers. I need to forward the incoming connection from server A (220.127.116.11:25565) to server B (18.104.22.168:25598) (as an example). I've tried multiple iptables rules, with partial success. The problem is the fact that the IP is not forwarded.
As an example, I have a Minecraft server. When there is a connection, it forwards me from 22.214.171.124 to 126.96.36.199, however, the IP that players have is not their network IP, but server A IP (188.8.131.52 in the current example). Would it be possible to somehow forward the connected IP as well?
If that is not possible, is there a possibility that I send a packet with the connection so I can inform the game-server of what IP player is using and make the server change it from Server A IP to real Connection IP (like this plugin does)? From what I saw using it, it just splits the incoming connection packet and gets the connection IP, port and timestamp. Does anyone know how?
Rules that I tried:
# Rule 1 iptables -t nat -A PREROUTING -p tcp --dport 25568 -j DNAT --to-destination 184.108.40.206:30026 iptables -t nat -A POSTROUTING -j MASQUERADE # Rule 2 iptables -t nat -A PREROUTING -p tcp --dport 25599 -j DNAT --to-destination 220.127.116.11:30026 iptables -t nat -A POSTROUTING -p tcp -d 18.104.22.168 --dport 30026 -j SNAT --to-source 22.214.171.124 # Rule 3 iptables -t nat -A PREROUTING -p tcp -d 126.96.36.199 --dport 12222 -j DNAT --to 188.8.131.52:30026 iptables -A FORWARD -p tcp -d 184.108.40.206 --dport 30026 -j ACCEPT iptables -t nat -A POSTROUTING -j MASQUERADE
Don't look too much at ports, I know those are not the same at every command but those do not really matter.