Skip to content

Instantly share code, notes, and snippets.

@xandout
Created April 15, 2014 13:32
Show Gist options
  • Save xandout/10732969 to your computer and use it in GitHub Desktop.
Save xandout/10732969 to your computer and use it in GitHub Desktop.
Linux NAT Quick Config
echo 1 > /proc/sys/net/ipv4/ip_forward
#Assuming eth0 is connected to the Internet or other network and eth1 is connected to a private network
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment