One of the advantages of Software Defined Networking is the sheer flexibility - one doesn't have to bring hardware routers, bridges, gateways...to construct inter network connections.

Want a NAT Gateway? That's a service - you get a gateway without worrying about patching or maintaining the underlying hardware,

The downside, is of course, the cost. At a bare minimum, you are looking at $1 a day for most of these gateways - including a (Site to Site) VPN Connection.

If cost is a concern, one can create one's own NAT Gateway using standard linux IP Tables.

Fire up a Compute Instance (or an EC2) using your favorite linux flavor, and try these two commands.

1
2
sysctl -w net.ipv4.ip_forward=1
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

What's the Next Step after building my own NAT Instance on GCP?

Now, when you build your PRIVATE-ROUTING-TABLE (you should always have TWO separate routing tables - a PRIVATE-ROUTE-TABLE and a PUBLIC-ROUTE-TABLE), you can add a route to the internet that uses the NAT instance that you just created. Read this post (it is aws route specific, but the same routing applies to GCP)

That is, you would be saying DESTINATION 0.0.0.0/0 and Target is the NAT instance (private IP) you just spun up.  

Need a GCP Consultant?

Set up a 1 on 1 appointment with Anuj to assist with your GCP cloud journey.