Saturday, July 18, 2009

iptables NAT port forward

# The port forwarding
iptables -t nat -A PREROUTING -i ethX -p tcp -m tcp --dport 12345 \
-j DNAT --to-destination 10.10.10.10:12345

# The masquerade
iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE

# Don't forget to turn on ip_forwarding:
sysctl -w net.ipv4.conf.ethX.forwarding=1

No comments:

Post a Comment