NAT forwarding under Linux

Easy setup of NAT forwarding using iptables under Linux (this was only tested on Fedora 18):

EXTERNAL=wlan0
INTERNAL=p3p1
sysctl -w net.ipv4.ip_forward=1
iptables -F
iptables -A FORWARD -i $INTERNAL -j ACCEPT
iptables -A FORWARD -o $INTERNAL -j ACCEPT
iptables -t nat -A POSTROUTING -o $EXTERNAL -j MASQUERADE

Leave a Reply

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