Iptables: redirect port to other IP – port

Bschelst/ November 20, 2017/ Linux/ 0 comments

You can use the following shell commands in order to redirect a port to another port.

iptables -t nat -A PREROUTING -p tcp --dport $PORT_FROM -j DNAT --to $DEST:$PORT_TO 
iptables -t nat -A POSTROUTING -p tcp -d $DEST --dport $PORT_TO -j MASQUERADE
Share this Post

Leave a Comment

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