1

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?

1
  • Is the game server using TCP or UDP (ports)? Jul 31, 2014 at 10:54

1 Answer 1

3

Use the REDIRECT target in the nat table, in the PREROUTING chain. Assuming the server uses TCP, run this command as root:

iptables -t nat -I PREROUTING -p tcp -m tcp --dport 443 \
                -j REDIRECT --to-ports 25565

If the server uses UDP, replace tcp with udp.

1
  • Hi Cristian, thanks for your quick answer. It is using TCP. I am going to test this and will come back to you with the results. Jul 31, 2014 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .