I am looking for a way to forward 1 port to another internally.
I have an Ubuntu 14.04 server on which I installed a game server that listens on port 25565.
The game does not support multiple ports.
I need to connect to this server from another place via port 443 only.
How do I make it so that when connecting via port 443 the firewall will forward to port 25565 so the game gets the request. And if the game wants to respond transfers it back to port 443 (only if a person was connected via 443).
And if someone connects via 25565 it responds like in the normal case via 25565.
How do I do this with iptables?
Best Answer
Use the
REDIRECT
target in thenat
table, in thePREROUTING
chain. Assuming the server uses TCP, run this command as root:If the server uses UDP, replace
tcp
withudp
.