Prepare and test your skills

Prepare and test your skills

Cloud NAT (opens in a new tab) is a fully managed, software-defined network address translation service in Google Cloud. Cloud NAT provides outbound translation for traffic from a Virtual Private Cloud (VPC) network to the internet, to other VPC networks, to on-premises networks, and to other cloud provider networks. Cloud NAT is distributed and does not depend on proxy virtual machines (VMs), appliances, or a single physical gateway device. A Cloud NAT gateway is created in the same region as the subnets that need translation, and translation is then applied automatically to matching resources in those subnets.
Cloud NAT translates addresses for the following Google Cloud resources when they use served subnets:
Outbound access for private VMs through Cloud NAT works by sharing a set of external addresses and ports instead of giving each VM its own external IP address. A Cloud NAT gateway allocates a set of external IP addresses and source ports to each VM that uses the gateway, and outbound traffic flows from the VM internal address through the gateway to the internet destination. For example, VM-1 in subnet-1 has no external IP address but needs to download updates, so a gateway configured for the address range of subnet-1 lets VM-1 send traffic by using its internal address. Cloud NAT performs source network address translation (source NAT or SNAT) for outbound packets and destination network address translation (destination NAT or DNAT) for the matching inbound responses.

A sequence diagram showing VM-1 sending outbound traffic through Cloud NAT with SNAT to the internet and DNAT for the established response, while unsolicited inbound is blocked.
The translation path depends on two planes with separate responsibilities. A Cloud Router provides the control plane for Cloud NAT and holds the configuration parameters, while Andromeda software implements the data-plane translation as the software-defined networking stack that powers the VPC network. Google Cloud runs and maintains the translation processes on the physical machines that host the VMs, so there is no customer-managed NAT VM in the path.
Public NAT and Private NAT are the two translation types offered by Cloud NAT gateways. A single gateway provides either Public NAT or Private NAT, while two separate gateways can serve the same subnet when both types are needed. Both types can translate addresses from IPv4 to IPv4 and from IPv6 to IPv4.
| NAT type | What it connects | How it translates |
|---|---|---|
| Public NAT | Resources without external IPv4 addresses to IPv4 destinations on the internet | Translates private internal addresses to a set of shared external IP addresses and source ports |
| Private NAT | Private addresses to other VPC networks, the same VPC network for IPv6, or on-premises and other-cloud networks | Translates overlapping private source addresses to unique addresses from the Private NAT subnet range |
Public NAT is used when private VMs, GKE nodes, and serverless resources need internet access for tasks such as downloading updates or completing provisioning. Private NAT is used when IPv4 subnets overlap between the VPC network and the destination network, because the gateway translates source traffic to unique addresses that can reach the non-overlapping subnets of the destination. Regional internet NEGs are supported by Public NAT and are not applicable to Private NAT.
Security through Cloud NAT comes from allowing only outbound-initiated connections and their established responses. Cloud NAT supports address translation for established inbound response packets only and does not allow unsolicited inbound connections from the internet to reach a private VM. This design lets teams remove external IP addresses from VMs that do not need to be directly reachable while still permitting those VMs to initiate outbound access. Outbound access through Cloud NAT remains subject to egress firewall rules, so firewall policy still controls which destinations a private VM can reach.
With manual NAT IP address assignment for Public NAT, the gateway uses a known set of common external source IP addresses that can be shared with a destination party for allowlisting. Traffic to Google APIs and services is routed through Private Google Access even when the initiating VM uses Public NAT, so that API traffic does not leave through the NAT internet path.
Exam tip: Cloud NAT permits DNAT only for established inbound response packets to an outbound connection; it never creates a path for an unsolicited inbound connection.
NAT IP allocation for a Public NAT gateway controls how external addresses are supplied as demand changes. With automatic allocation, Cloud NAT can automatically scale the number of NAT IP addresses that it uses, which supports fleets that grow and shrink, including VMs in managed instance groups with autoscaling enabled. With manual NAT IP address assignment, the administrator fixes the set of external addresses so the same source addresses are presented to external destinations. Cloud NAT does not reduce the network bandwidth per VM because forwarding is handled by the distributed Andromeda data plane rather than a single gateway choke point.
Observability for Cloud NAT combines logs, metrics, and configuration analysis for operations under changing load. Cloud NAT logging traces connections and bandwidth for compliance, debugging, analytics, and accounting purposes. Cloud NAT also sends key gateway metrics automatically to Cloud Monitoring for dashboards, alerts, and queries, and Network Analyzer automatically monitors Cloud NAT configuration to generate Cloud NAT insights.
The combined use of Cloud DNS (opens in a new tab) and Cloud NAT (opens in a new tab) supports secure multi-tier and hybrid architectures with controlled name resolution and controlled outbound connectivity. In this design, Cloud DNS handles how names resolve across the hub, spokes, and on-premises, and Cloud NAT handles how private source addresses translate toward the internet or toward overlapping private networks. Together they let private workloads resolve names in every environment but only initiate intended outbound connections.
Public NAT for controlled internet egress lets Google Cloud resources without external IPv4 addresses communicate with IPv4 destinations on the internet. A Cloud NAT gateway is created in the region of the subnets that need translation, and translation is then automatically applied to matching resources in those subnets. For example, VM-1 in subnet-1 has only an internal IP address, but after the gateway is configured to serve subnet-1, VM-1 can send outbound traffic to download updates by using its internal address. Public NAT does not use proxy VMs or appliances, and the gateway allocates a set of shared external IP addresses and source ports to each VM.
The gateway applies source NAT on outbound packets and destination NAT only for established inbound response packets, so internet hosts cannot initiate new sessions into private VMs through the gateway. Public NAT applies to the following resource types when they use the served subnets:
Exam tip: Traffic to Google APIs and services uses Private Google Access even when the VM uses Public NAT, so Public NAT does not carry that API traffic to the internet.
Private NAT for overlapping private networks provides private-to-private translation between VPC networks or between a VPC network and on-premises or other cloud provider networks. When Private NAT is configured, the gateway translates source traffic by using IP addresses from a Private NAT subnet range. This translation to unique addresses lets Google Cloud resources reach non-overlapping subnets on the other side even when the original IPv4 ranges overlap. Private NAT supports translation for traffic to another VPC network attached to a Network Connectivity Center hub, for IPv6 traffic within the same VPC network, and for on-premises or other-cloud networks connected through Network Connectivity Center hybrid spokes or through Cloud Interconnect or Cloud VPN.
The choice between Public NAT and Private NAT depends on destination and purpose:
| Type | Destination | Choose when |
|---|---|---|
| Public NAT | IPv4 destinations on the internet | Private VMs need outbound internet access without individual external IP addresses |
| Private NAT | Another VPC network, same VPC network, or on-premises or other-cloud network | Private address ranges overlap or private networks must connect without using public addresses |
Both Public NAT and Private NAT can translate IPv4 to IPv4 and IPv6 to IPv4. A single Cloud NAT gateway provides either Public NAT or Private NAT, but two separate gateways can serve the same subnet when both types are needed.
VPC design with Cloud NAT is regional, distributed, and firewall-controlled rather than appliance-based. Cloud NAT architecture is a distributed, software-defined managed service powered by Andromeda software, not by proxy VMs or a single physical gateway device. You configure the gateway on a Cloud Router, which provides the control plane that holds the configuration parameters, while Google Cloud runs the translation processes on the physical machines that host the VMs. Because the gateway is regional and serves only the subnets you specify, VPC design must place the gateway in the same region as the workloads that need translation.
Outbound access through Public NAT remains subject to egress firewall rules, so a VM without an external IP address can reach the internet only when firewall rules allow that egress. With manual NAT IP address assignment, the gateway uses a fixed set of common external source addresses that can be shared with a destination party for allowlisting. Cloud NAT can automatically scale the number of NAT IP addresses it uses, supports VMs in managed instance groups including groups with autoscaling, and does not reduce network bandwidth per VM.
A hybrid hub-and-spoke design with Cloud DNS and Cloud NAT connects a hub VPC network to spoke VPC networks and to on-premises with parallel DNS and routing paths. In this model, on-premises DNS servers remain authoritative for corp.example.com, while Cloud DNS hosts a private zone such as projectX.gcp.example.com in each spoke for resources in that spoke. The hub provides inbound DNS forwarding for on-premises queries and outbound forwarding for corp.example.com to on-premises servers, and peering zones connect the hub to each spoke and each spoke back to the hub. Traffic flows from spoke workloads to the hub forwarder for cross-environment names, and from on-premises resolvers to the hub inbound forwarder address for Google Cloud names.
Firewalls on both sides must allow DNS traffic, and the hub Cloud Router must advertise a custom route for 35.199.192.0/19 to on-premises so return traffic for the forwarding path can route correctly. To build this architecture, complete the steps in order:
corp.example.com.projectX.gcp.example.com, with records for that spoke.corp.example.com in the hub VPC network with outbound forwarding to on-premises DNS servers.projectX.gcp.example.com.example.com.gcp.example.com to the inbound forwarder address in the hub VPC network.35.199.192.0/19 on hub Cloud Routers toward on-premises..internal zone with the hub and forward .internal queries from on-premises when automatic internal names are also used.Availability and performance with Cloud NAT come from its distributed design and software-defined forwarding path. Cloud NAT availability comes from its distributed design, because it does not depend on any VM in the project or on a single gateway device. The Cloud Router holds configuration as the control plane, while Google maintains the underlying processes, so there is no customer-managed NAT appliance to become a single point of failure. For performance, translation is applied in the software-defined network path without reducing per-VM bandwidth.
Operations for private multi-tier workloads combine firewall-controlled egress, routed DNS forwarding paths, regional gateway placement, and built-in observability. Cloud NAT provides logging to trace connections and bandwidth for compliance, debugging, analytics, and accounting. Cloud NAT also sends key gateway metrics automatically to Cloud Monitoring for dashboards, alerts, and queries, and Network Analyzer generates Cloud NAT insights by monitoring the configuration.
Cloud DNS (opens in a new tab) is a high-performance, resilient, global Domain Name System (DNS) service that publishes domain names without requiring you to manage DNS servers or software. DNS is a hierarchical distributed database that stores IP addresses and other data so they can be looked up by name. Cloud DNS serves those lookups with low latency and high availability as an authoritative server for both internet-visible names and internal names used inside Google Cloud.
A Cloud DNS managed zone is a container for DNS records for a specific portion of the DNS namespace, such as example.com, that you manage as one unit. Cloud DNS offers two visibility types for managed zones, and the type controls who can resolve names in the zone. You create and manage zones per project, and you can control access with Identity and Access Management (IAM) permissions at the project level and at the individual zone level.
| Zone type | Visible to | Use when |
|---|---|---|
| Public zone | The public internet | The service must be reachable by users outside Google Cloud, such as www.example.com |
| Private zone | Only the Virtual Private Cloud (VPC) networks you authorize | The service must stay internal, such as application servers or databases that must not be exposed externally |
A private zone answers queries only from the VPC networks listed as its authorized networks. In Shared VPC, create the private zone in the host project and then add one or more Shared VPC networks to its authorized networks, or use cross-project binding to attach a zone created in a service project. To follow least privilege, grant only DNS-specific roles such as DNS Administrator and avoid broad basic roles, and use the dns.networks.bindPrivateDNSZone permission when you need to separate who can create private zones from who can create public zones.
DNS records in Cloud DNS associate a domain name with a value, such as an IP address, another domain name, or text. Records that share the same name, type, and TTL are managed together as a set, and each record type serves a different purpose for directing traffic, mail, and verification:
TTL, or Time-To-Live, controls how long resolvers may cache a record set before asking Cloud DNS again. Because Cloud DNS is authoritative for the zones it hosts, clients receive answers directly from Cloud DNS data rather than from a zone transfer or manual server sync.
Cloud DNS integration with VPC networks means private name resolution follows the VPC boundary you configure. When a virtual machine in an authorized VPC network queries a name in a private zone, the query flows from the VM to Cloud DNS and Cloud DNS returns the private record answer. When a VM is in a VPC network that is not authorized for that private zone, Cloud DNS does not make that private zone visible to that VM. This VPC attachment model is what provides scalable and low-latency internal resolution.
There are no DNS server virtual machines to size, patch, or replicate because the Cloud DNS control plane serves the zone data globally and applies the same authorized-network check for every query. Teams can still delegate safely by automating record creation through approved tools such as Terraform or an internal API backed by a service account, so many teams can use subdomains without gaining broad access to the host project.
Exam tip: A public zone is authoritative and visible to the public internet, while a private zone is visible only from the VPC networks you authorize — choose private when the name must never resolve externally.
Public NAT connects resources without external IPv4 addresses to IPv4 destinations on the internet by translating private internal addresses to a set of shared external IP addresses and source ports, while Private NAT translates overlapping private source addresses to unique addresses from the Private NAT subnet range for connections to other Virtual Private Cloud (VPC) networks, on-premises networks, and other cloud provider networks. A single Cloud NAT gateway provides either Public NAT or Private NAT, but two separate gateways can serve the same subnet when both types are needed. Both types can translate addresses from IPv4 to IPv4 and from IPv6 to IPv4.
Cloud NAT enables outbound access by allocating a set of external IP addresses and source ports to each virtual machine and performing source network address translation (source NAT or SNAT) for outbound packets and destination network address translation (destination NAT or DNAT) only for the matching established inbound response packets. It does not allow unsolicited inbound connections from the internet to reach a private virtual machine, so teams can remove external IP addresses from virtual machines that do not need to be directly reachable. Outbound access through Cloud NAT remains subject to egress firewall rules, so firewall policy still controls which destinations a private virtual machine can reach.
A Cloud DNS public zone is visible to the public internet and is used when a service must be reachable by users outside Google Cloud, while a Cloud DNS private zone is visible only from the authorized Virtual Private Cloud (VPC) networks you specify. When a virtual machine in an authorized Virtual Private Cloud (VPC) network queries a name in a private zone, Cloud DNS returns the private record answer, and when the virtual machine is in a network that is not authorized, Cloud DNS does not make that private zone visible to it.
Cloud Router provides the control plane for Cloud NAT and holds the configuration parameters, while Andromeda software implements the data-plane translation as the software-defined networking stack that powers the Virtual Private Cloud (VPC) network. Google Cloud runs and maintains the translation processes on the physical machines that host the virtual machines, so there is no customer-managed NAT virtual machine in the path. A Cloud NAT gateway is created in the same region as the subnets that need translation, and translation is then applied automatically to matching resources in those subnets.
An organization runs backend application workloads on Google Compute Engine virtual machine (VM) instances inside a custom VPC subnet. To maintain a strong security posture, none of the VM instances have external IPv4 addresses assigned to their network interfaces.
The applications on these VMs require access to the public internet to download critical operating system patches and repository updates. However, security policy strictly prohibits systems on the public internet from initiating inbound connections to these instances.
Which Google Cloud networking solution should you implement to meet these requirements?
Last updated