Pages

Friday, February 7, 2014

Port Forward for NAT Server Using iptables


NAT Server WAN IP (Port 20022)
                1.2.3.4

Internal Server IP (Listen Port 22)
                192.168.137.25

1.2.3.4:20022 => 192.168.137.25:22


Enable Port Forward 20022 to 22
iptables -t nat -I PREROUTING -p tcp --dport 20022 -s 1.2.3.4 -j DNAT --to-destination 192.168.137.25:22


Enable Masquerade for port 22
iptables -t nat -A POSTROUTING -p tcp --dport 22 -j MASQUERADE