IPtables Port Redirection

Here’s the command-by-command reference of how to forward TCP port 80 on the local host to a remote host (10.1.21.21) on TCP port 8080.

# iptables -F
# iptables -X
# iptables -t nat -A OUTPUT -d 10.1.21.21 -p tcp –dport 80 -j REDIRECT –to-ports 8080
# iptables -t nat -A PREROUTING -d 10.1.21.21 -p tcp –dport 80 -j REDIRECT –to-ports 8080

# /etc/init.d/iptables save
# /etc/init.d/iptables restart
# chkconfig iptables on

Leave a Reply

Your email address will not be published / Required fields are marked *