Port forward using iptables

Written by Yujin Boby

Edit in WordPress

To forward all requests from port 80 to port 8080, run

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Here is another command that specify network interface and forward traffic on port 80 to port 5000

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5000

Back to iptables