Skip to content

Instantly share code, notes, and snippets.

@wakwanza
Created April 5, 2015 12:16
Show Gist options
  • Save wakwanza/3c08eedf6d40f60f4968 to your computer and use it in GitHub Desktop.
Save wakwanza/3c08eedf6d40f60f4968 to your computer and use it in GitHub Desktop.
Create NAT route on GCE
#!/bin/bash
#
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT
sudo service iptables save
sudo sed -i 's/.*net.ipv4.ip_forward = 0*/net.ipv4.ip_forward = 1/' /etc/sysctl.conf
sudo sysctl -e -p /etc/sysctl.conf
sudo service iptables restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment