Enable Public Internet Communication Using Cloud NAT on GCP

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Cloud NAT (network address translation) allows instances with no public IP address to continue to communicate with the public Internet when they need external resources. This lab will take you through the steps of creating a managed Cloud NAT gateway for one subnet in a custom VPC network, while leaving a second subnet (with a private instance) cut off from Internet access.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

SSH into Private Instances and Confirm Lack of External Internet Connectivity
  1. From the web console, go to the top left menu and select Compute Engine.

  2. Click the SSH button next to both private-instance-1 and private-instance-2 to open SSH sessions.

  3. In each SSH session, attempt to ping google.com. It should be unsuccessful.

  4. Leave the SSH windows up, and go back to the web console.

Create a Cloud NAT Gateway
  1. From the web console, go to the top left menu and select first Network Services, then Cloud NAT.

  2. Click Get started.

  3. Name the gateway "nat-1".

  4. Under the VPC network menu, select custom-network.

  5. Set region to us-central1.

  6. Under the Cloud Router menu, select Create new router.

  7. Name the router "nat-router".

  8. Click Create.

  9. Under NAT mapping – Source, change the source to "Custom".

  10. Under the Subnet name menu, select subnet-a.

  11. Leave all other settings as defaults, and click Create. After about 15 seconds, your Cloud NAT gateway should be up and running.

Test NAT Translation
  1. Go back to the SSH session for private-instance-1.

  2. Attempt to ping google.com. It should be successful.

  3. Go back to the SSH session for private-instance-2.

  4. Attempt to ping google.com. It should not be successful because we did not place instances in subnet-b behind our NAT gateway.

Additional Resources

Cloud NAT allows GCE instances without a external IP address to communicate with the public Internet. In this lab, we will create a managed Cloud NAT gateway to enable public communications with some, but not all, of our private resources.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?