0

How do I use iptables to forward all requests to a port (say 1443) to another port on the same host (say 443)?

This should also be done for requests from another computer.

3
  • why do you need this if I may ask? Nov 8, 2014 at 19:30
  • @HrvojeŠpoljar Some applications that can't guarantee they will be started by UID 0 start on a high-number port by default, and it is up to you to reconfigure or NAT/Proxy if you want to use on a lower port. For example, Tomcat Java application container runs on ports 8080 and 8443 by default. If I recall correctly, BT Diamond's IPControl DNS engine runs on a high-numbered port and expects either IPTABLES-based NAT or a forwarding/caching BIND on port 53 to get to it.
    – DTK
    Nov 8, 2014 at 19:41
  • 2
    I see, this approach also requires root access. But certainly if some application is not safe; it's better to run it as normal user than as root. Normally applications run as root and then privileges are dropped to user privileges when it 'daemonizes'. Nov 8, 2014 at 19:43

1 Answer 1

2

You need rule which will update 'nat' tables PREROUTING chain like this :

iptables -t nat -A PREROUTING -p tcp --dport 1443 -j REDIRECT --to-port 443

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