Open In App

How to Use Cloud NAT For Outbound Internet Access on GCP?

NAT Gateway is a Network address translation gateway that enables multiple devices to access a public network through a single IP address. It is mainly used to conserve registered IP addresses and use private IP addresses instead. Cloud NAT is used to expose internal private resources to the internet. We will see step by step process to do the same.

Types of NAT Gateways

The major difference between public and private NAT is private NAT gateway uses a private IP address that is used to map to internal private IP addresses of resources. This is helpful when an organization wants to restrict the use of IP addresses. Public NAT uses a registered Public IP address which is mainly used to connect to the internet or public network.



Steps to Configure Cloud NAT in GCP

Step 1: Firstly to configure cloud NAT we will setup a VM inside VPC network. Go to compute engine and select VM Instances and click on create instance .On create instance page specify options as below. specify name for instance and select region and zone . Select size for VM according to your requirement.



Step 2: Keep other options as default . Now click on Networking under advanced . Under networking specify your VPC network and subnet where you want to deploy VM.

Step 3: Now under IP address specify external IP address as none .

Step 4: Leave other options as default and click on create . Once the VM is ready click on SSH .

Step 5: Once logged in ping to any website using ping command . You should see you cant access internet. Close the SSH .

Step 6: To enable internet access we will now configure NAT gateway . Navigate to Cloud NAT on GCP and click on Get Started . On NAT gateway creation page specify name and select VPC network and subnet same as VM instance .

Step 7: For cloud router select create new . Give name to router and then click create.

Step 8: After creating router leave other options as default and then click create. Once the NAT gateway is setup you should see running status .

Step 9: Now go back and connect to instance using SSH . Again ping to the same site as before . You should see you can access internet .

Thus we have configured public NAT gateway in GCP for outbound internet access .

Troubleshooting

Conclusion

From this article we have seen what is Cloud NAT in GCP . We have also seen step by step process to configure Cloud NAT gateway in GCP.

FAQs on Cloud NAT

1. Why There Is Need Of NAT Gateway In GCP ?

NAT gateway is majorly used to aceses the internet from the private instance without using the public IP address

2. What Are Possible Use Cases To Use NAT ?

Here are the some Possible Use Cases:

  1. Outbound Internet Access for Private Subnets.
  2. Security and Isolation.
  3. Egress Control.
  4. P Address Conservation.

Article Tags :