TCP port forwarding with linux iptables NAT, PREROUTING and DNAT example

Lets say that we would like to do port forwarding from our network interface eth0 on port 23  (telnet) to socket 10.0.0.1:23 (ip address:port):

iptables -t nat -I PREROUTING -p tcp -i eth0 –dport 111 -j DNAT –to 10.0.0.1:23

other example:

to do port forward from eth0 on port 456 to 192.168.0.1:788

iptables -t nat -I PREROUTING -p tcp -i eth0 –dport 456 -j DNAT –to 192.168.0.1:788

Leave a Reply

You must be logged in to post a comment.