Cloud NAT in Google Cloud: The Complete Intermediate Guide

Cloud NAT in Google Cloud: The Complete Intermediate Guide

Understand how private machines reach the internet and other networks without public addresses, from gateways and ports to rules, logging, and real-world design choices, explained step by step in plain English.

Picture a large office building with one main reception desk and one public phone number. Hundreds of employees sit inside, each with a private extension that outsiders can never dial directly. When an employee calls a customer, the call leaves through the building’s main line, and the customer sees only that single public number. When the customer calls back, the switchboard knows which employee started the conversation and connects the reply to the right desk. Nobody outside can phone an employee out of the blue. Cloud NAT is that switchboard for your machines in Google Cloud.

This guide explains Cloud NAT from the first idea to production-grade design choices. You do not need any networking background. Every new word is explained the first time it appears, with an everyday comparison. By the end you will know what Cloud NAT does, what it deliberately does not do, how it shares addresses and ports, how to avoid its classic traps, and how to watch it in production.

1What Cloud NAT Is and Why It Exists

Cloud NAT lets resources that have only private addresses start connections to the outside world, while keeping the outside world from starting connections to them.

The problem: private machines still need to reach out

Good security practice says most servers should not have a public internet address. A machine without a public address cannot be reached directly from the internet, which removes a huge category of attacks. But those same machines still have errands to run. They download operating system updates, call payment providers, fetch software packages, talk to third-party APIs, and send data to partner companies. Without a public address, none of these outbound requests can leave the network, because nobody on the internet knows how to send the answer back to a private address.

The traditional fix is to give every machine a public address, which brings back the exposure you wanted to avoid. The better fix is Network Address Translation, usually shortened to NAT. A NAT service rewrites the sender address on outgoing packets to a shared public address, remembers who asked, and delivers the answers back to the right private machine.

Simple Analogy

Think of a company mailroom. Employees hand outgoing letters to the mailroom, which stamps the company’s public return address on each one. When replies arrive, the mailroom checks its log and delivers each reply to the employee who wrote the original letter. Strangers can mail the company’s front desk all day, but the mailroom will never deliver a letter to an employee who did not ask for one.

What Cloud NAT is, in one paragraph

Cloud NAT is Google Cloud’s managed network address translation service. According to Google’s documentation, it provides translation for outbound traffic to the internet, to other VPC networks, to on-premises networks, and to other cloud providers’ networks. It works for Compute Engine virtual machines, Google Kubernetes Engine clusters, Cloud Run, Cloud Run functions, App Engine standard instances, and regional internet network endpoint groups. You create a Cloud NAT gateway in a region, tell it which subnets it should serve, and the translation starts applying automatically to matching resources.

A key idea: it is not a virtual machine

Many beginners picture Cloud NAT as a special server sitting in the middle, like a router appliance that traffic must squeeze through. It is not. Google describes it as a distributed, software-defined managed service that does not depend on proxy virtual machines or a single physical gateway. It programs Google’s Andromeda network virtualization software, so the translation happens at the edge of each virtual machine’s own network path. There is no central box to size, patch, or crash, and it does not reduce the network bandwidth available to each machine.

Outbound
connections start inside and go out
0
proxy VMs or appliances for you to manage
Regional
a gateway serves subnets in one region
i
Good to Know

Cloud NAT is not a firewall and not a load balancer. It never makes your private machines reachable from outside. Firewall rules still decide what traffic is allowed, and load balancers handle traffic that outsiders start toward your services.

Where Cloud NAT fits among Google Cloud networking tools

Google Cloud offers several networking building blocks, and beginners often confuse them because they all move packets. A load balancer receives traffic that outsiders send toward your services and spreads it across healthy backends. A firewall rule decides whether a packet is allowed to pass at all. A Cloud VPN or Cloud Interconnect link connects your cloud network to another network, such as an office or a data center. Cloud DNS turns names into addresses. Cloud NAT does one narrow job: it changes the sender address of outbound traffic so private resources can start conversations without owning public addresses.

Seeing these tools as a team makes design easier. For a typical web application, the load balancer handles visitors coming in, the firewall limits what is allowed, Cloud DNS provides names, and Cloud NAT lets servers call out. Each tool can be changed on its own without breaking the others, as long as you understand which direction of traffic each one owns.

Simple Analogy

A hotel has a reception desk for arriving guests (the load balancer), security staff who check badges (firewall rules), a phone directory (DNS), a private tunnel to the sister hotel (VPN), and a mailroom for outgoing letters (Cloud NAT). Nobody asks the mailroom to greet guests.

2Core Concepts You Must Know First

A few small ideas about addresses and ports explain nearly everything about Cloud NAT.

Networking vocabulary can feel like alphabet soup, so let us build it slowly. Each term below appears again and again in Cloud NAT documents, and once you understand them the rest becomes natural.

Term 1

IP Address

A number that identifies a machine on a network, like a house number on a street. It tells packets where to go.

Term 2

Private vs Public IP

Private addresses work only inside a network and cannot be reached from the internet. Public addresses are reachable worldwide.

Term 3

Port

A numbered door on an address. The address picks the building, and the port picks the apartment inside it.

Term 4

Source NAT (SNAT)

Rewriting the sender address and port on outgoing packets. This is what makes private machines look like they come from a public address.

Term 5

Destination NAT (DNAT)

Rewriting the destination of returning packets back to the original private address and port, so the answer reaches the right machine.

Term 6

VPC Network

Your own private network inside Google Cloud, divided into regional subnets where your resources live.

Term 7

Cloud Router

A managed control-plane service that holds routing and NAT configuration for a network in a region.

Term 8

NAT Gateway

The Cloud NAT configuration object you create on a Cloud Router, choosing which subnets and addresses it uses.

Addresses and ports work as a pair

A connection is identified by more than just an address. It is identified by the source address, source port, destination address, destination port, and protocol, together called the connection tuple. When your virtual machine opens a connection to a website, it picks a random source port for that conversation. If a hundred machines share one public address, the NAT service must keep their conversations apart. It does this by giving each conversation its own public address and port combination and remembering the mapping.

Simple Analogy

Imagine an apartment building with one street address. Mail addressed only to the building would be chaos, so each resident gets an apartment number. The public address is the building, the port is the apartment number, and Cloud NAT is the doorman who knows which resident sent which letter.

Why ports are a limited resource

There are only about 64,000 usable ports on a single address, and ports below 1024 are reserved. Every active outbound conversation uses one of them. That limit is the root of the most common Cloud NAT problem, port exhaustion, which later chapters cover in depth. If you remember only one idea from this chapter, remember that Cloud NAT shares a limited pool of address and port pairs among many machines.

!
Common Misconception

Many people think NAT is a security feature that hides and protects servers. Hiding private addresses is a side effect, not the purpose. Real protection comes from firewall rules, careful identity, and not exposing services you do not intend to expose.

Inbound and outbound are different worlds

Most NAT confusion comes from mixing up direction. An outbound connection starts inside your network and goes out, such as a server downloading a file. An inbound connection starts outside and comes in, such as a visitor opening your website. Cloud NAT is built for the first kind. For the second kind, a different product receives the traffic first. Keeping this direction clear in your head, and in your diagrams, prevents a whole class of design errors and wasted troubleshooting.

3Public NAT and Private NAT

Cloud NAT comes in two flavors, one for reaching the internet and one for reaching other private networks.

Public NAT: private machines reaching the internet

Public NAT lets resources that have no external IPv4 address reach IPv4 destinations on the internet. It uses a set of shared external IP addresses, and it allocates external addresses and source ports to each virtual machine that uses the gateway. This is the version most people mean when they say Cloud NAT. It is how a locked-down application server downloads a software package or calls a payment provider.

Google’s documentation points out one subtle exception. Traffic to Google APIs and services travels through Private Google Access, even when Public NAT exists. Those requests do not consume your NAT addresses and ports, because Google’s own services are reachable over Google’s internal network.

Private NAT: private to private translation

Private NAT solves a different problem. Sometimes two private networks need to talk, but their address ranges overlap, which is like two cities that both have a “Main Street 10”. Private NAT translates the source addresses into unique ones taken from a dedicated Private NAT subnet range, so the two sides can communicate without renumbering either network. According to the documentation, Private NAT supports translation toward other VPC networks attached to a Network Connectivity Center hub, translation for IPv6 traffic within the same VPC network (known as NAT64), and translation toward on-premises or other cloud networks through hybrid spokes, Cloud Interconnect, or Cloud VPN, often called Hybrid NAT.

flowchart LR
  VM1["VM with private IP only"] --> PUB["Public NAT gateway"]
  PUB --> NET["Internet destinations"]
  VM2["VM in VPC A"] --> PRIV["Private NAT gateway"]
  PRIV --> OVER["Network with overlapping ranges, on-premises or another VPC"]
        
FIG 1 — Public NAT for the internet and Private NAT for private networks

Read the diagram as two separate roads. The top road carries outbound internet traffic through a Public NAT gateway. The bottom road carries traffic to other private networks through a Private NAT gateway. A single gateway is one type or the other, but two gateways, one of each type, can serve the same subnet.

QuestionPublic NATPrivate NAT
Where does traffic go?Internet destinationsOther VPCs, on-premises, other clouds
What addresses are used?Shared external IP addressesAddresses from a Private NAT subnet range
Main useOutbound access without public IPsOverlapping ranges, hybrid connections, NAT64
Typical senderServer, container, serverless workloadWorkload in a connected private network
Simple Analogy

Public NAT is the company’s main phone line to the outside world. Private NAT is the translation desk between two branch offices that happen to use the same room numbers, so each side assigns temporary unique numbers to visitors from the other.

IPv6 and NAT64

Much of the internet still speaks IPv4, while new networks increasingly use IPv6. Google’s release notes show that IPv6-to-IPv4 translation, called NAT64, became generally available for Public NAT in August 2025, and for Private NAT in October 2026. This lets IPv6-only workloads reach IPv4-only destinations through the gateway. If your organization is moving toward IPv6, it is worth knowing this bridge exists.

Choosing between the two

A simple question decides most cases: where is the destination? If the destination is a public service on the internet, such as a software repository, a payment provider, or a public API, you want Public NAT. If the destination is another private network, such as an on-premises data center, another company’s network, or another VPC network connected through Network Connectivity Center, you want Private NAT, especially when address ranges overlap. If both kinds of destinations exist, you can run one gateway of each type on the same subnet.

Do not choose Private NAT just because your destination sits on a private address. If ranges do not overlap and routing already works, plain routing needs no translation at all. Translation adds a mapping to manage and a layer to debug, so use it only when it solves a real problem such as overlapping ranges, controlled address exposure, or an IPv6-to-IPv4 bridge.

4Architecture and Components

A gateway lives on a Cloud Router, applies to chosen subnets in one region, and uses a pool of addresses.

The pieces and how they connect

Start with your VPC network, which contains regional subnets. In a given region you create a Cloud Router, a managed control-plane service that stores configuration. On that router you create a NAT gateway. The gateway lists which subnets, or which address ranges inside them, it should translate. It also lists where its public addresses come from: either addresses that Google allocates automatically, or addresses you reserve yourself.

flowchart TD
  VPC["VPC network"] --> SUB["Regional subnet"]
  SUB --> VM["VMs, GKE nodes, serverless egress"]
  CR["Cloud Router in the same region"] --> GW["Cloud NAT gateway"]
  GW --> IPS["External IP pool, automatic or manual"]
  VM -->|"Outbound packets"| GW
  GW -->|"Translated packets"| NET["Internet"]
        
FIG 2 — Components of a Cloud NAT setup

Notice that the Cloud Router is not in the data path. It only carries the configuration. The real translation is performed by Google’s Andromeda software, which Google says is configured to perform source NAT for outgoing traffic and destination NAT for established inbound responses. This is why Cloud NAT scales without you adding machines.

Simple Analogy

The Cloud Router is like the rulebook kept in the head office, while the translation is carried out by a doorman at every building entrance. The rulebook does not stand in the doorway, but every doorman follows it.

Regional by design

A Cloud NAT gateway is created in the region of the subnets that need NAT. If your application runs in two regions, you need a gateway in each. This regional design matches the way Google Cloud networks are built, and it keeps traffic from needing to travel across regions just to be translated.

What the gateway applies to

You do not attach NAT to individual machines. You choose subnets or ranges, and any matching resource without its own external address is covered. Because of that, a machine added later by autoscaling is covered automatically. Google notes that Cloud NAT supports managed instance groups, including autoscaling groups, with no extra steps.

i
Design Tip

Choose NAT coverage by subnet purpose. Put workloads that must reach the internet in subnets that the gateway serves, and keep other subnets, such as database subnets, outside it. That makes the policy visible in your network layout.

!
Common Mistake

Assuming a machine with its own external IP address will use the NAT gateway. A machine that already has an external address uses it directly for internet traffic, so its traffic does not consume NAT ports.

What Cloud NAT needs from the rest of the network

A gateway cannot work alone. It needs a Cloud Router in the right region and network, subnets that contain the workloads, a route toward the internet gateway for public traffic, and firewall rules that allow the outbound connections. It also needs external addresses, either supplied automatically or reserved by you. When all of these line up, translation is invisible. When one is missing, the symptom is usually a timeout, which is why walking through each requirement is such a reliable debugging habit.

5How Cloud NAT Works Internally

Every outbound conversation gets an entry in a mapping table that links a private address and port to a public address and port.

The translation, step by step

When a virtual machine sends a packet to an internet destination, the packet leaves with the machine’s private address as its sender. Cloud NAT notices that the packet matches a configured subnet, picks an external address and source port from those reserved for that machine, rewrites the sender fields, and forwards the packet. It records the mapping. When the destination replies, the reply arrives at the public address and port, Cloud NAT finds the mapping, rewrites the destination back to the private address and port, and delivers the packet to the original machine.

sequenceDiagram
  participant VM as VM private IP
  participant NAT as Cloud NAT
  participant WEB as Internet server
  VM->>NAT: Request from private IP and port
  NAT->>NAT: Pick public IP and port, record mapping
  NAT->>WEB: Request from public IP and port
  WEB-->>NAT: Reply to public IP and port
  NAT->>NAT: Look up mapping
  NAT-->>VM: Reply to private IP and port
        
FIG 3 — Outbound request and established reply

Why unsolicited inbound traffic is dropped

Google states that Cloud NAT supports address translation for established inbound response packets only. If a stranger on the internet sends a packet to your NAT address, there is no mapping for it, so there is nothing to translate and nowhere to deliver it. The packet is simply dropped. This is what keeps NAT-only machines unreachable from outside. If you want to receive inbound connections, you need a different tool, such as a load balancer.

Simple Analogy

The mailroom only delivers replies to letters it actually sent out. A letter arriving from a stranger with no matching record is returned or thrown away, no matter how politely it is addressed.

Ports are assigned to each machine

Cloud NAT does not let every machine grab ports from one big shared pool at random. It reserves blocks of ports for each machine that uses the gateway. This gives each machine a predictable share and prevents one noisy machine from silently taking everything. The number of ports reserved per machine is a setting you can tune, and getting it right is one of the most important Cloud NAT skills. The next chapters explain how.

Reusing ports for different destinations

A port is not permanently consumed by one connection. The same public address and port pair can be used for connections to different destinations, because the full connection tuple, which includes the destination, remains unique. This reuse is the reason a machine can hold far more active connections than it has reserved ports, as long as they go to many different destinations. It is also why connecting thousands of times to one single destination address and port is the most demanding pattern for NAT.

i
Memory Trick

Ask yourself how many connections go to the same destination address, port, and protocol. That one number, not total traffic volume, usually predicts whether NAT ports will run out.

What a mapping actually contains

Each entry in the translation table records the private source address and port, the public address and port chosen for it, the destination address and port, and the protocol. The protocol matters because TCP, UDP, and ICMP behave differently. TCP connections have a clear beginning and end, so the gateway can watch them open and close. UDP has no such lifecycle, so the gateway relies on idle timers to know when a conversation is over. ICMP, used by tools such as ping, also relies on timers and is supported by Public NAT.

Because the mapping includes the destination, two different conversations from the same machine can share a public address and port as long as they go to different destinations. When people say a machine “used up its ports”, they usually mean it used up distinct combinations toward one particular destination, not that it spoke to the internet too much overall.

i
Debugging Tip

When investigating a failure, always note the destination address, port, and protocol. Without those three, NAT problems are almost impossible to reason about, because the mapping and the limits depend on them.

6Data Flow and Gateway Lifecycle

It helps to know which traffic passes through the gateway, which traffic skips it, and how a gateway lives from creation to retirement.

Which traffic uses Cloud NAT

flowchart TD
  S["Packet leaves a VM"] --> Q1{"VM has its own external IP?"}
  Q1 -- "Yes" --> D1["Uses its own external IP, no NAT ports used"]
  Q1 -- "No" --> Q2{"Destination is a Google API?"}
  Q2 -- "Yes" --> D2["Private Google Access path, no NAT ports used"]
  Q2 -- "No" --> Q3{"Subnet covered by a NAT gateway?"}
  Q3 -- "Yes" --> D3["Source NAT applied, packet leaves"]
  Q3 -- "No" --> D4["No route out, connection fails"]
        
FIG 4 — Decision path for outbound packets

This flow explains several support tickets before they happen. If a private machine cannot reach a website, the cause is often that no gateway covers its subnet. If a machine has an external address and you expected NAT logs, the logs will be empty because it never used NAT. Remember also that firewall rules apply to the traffic before translation, so an egress rule that blocks the destination will stop the packet even when NAT is perfect.

The life of a gateway

1

Plan addresses and coverage

Decide which subnets need outbound access, whether addresses should be automatic or manual, and whether a partner needs a fixed list of addresses.

2

Create a Cloud Router and gateway

Create the router in the region, then add the NAT gateway with its subnet selection, address mode, and port settings.

3

Turn on logging and monitoring

Enable the logs you need and build dashboards for port usage and dropped connections before real traffic depends on the gateway.

4

Validate with real workloads

Run test connections from covered subnets, confirm the public address that destinations see, and check that allowlists at partners are correct.

5

Operate and tune

Watch port usage across busy periods and adjust ports and timeouts, always rehearsing risky changes first.

6

Change or retire carefully

Before removing addresses or a gateway, confirm nothing depends on them, because partners may still allow only those addresses.

!
Common Mistake

Forgetting that private clusters and private machines have no internet path at all until a gateway exists. A fresh private environment that cannot download images or packages usually just needs NAT.

Routes still matter

Cloud NAT does not replace routing. For internet-bound traffic from a private machine to leave the network, the VPC needs a route that points toward the default internet gateway, which is normally provided by the default route that new networks receive. If someone deletes that route, or replaces it with a custom route that sends everything to an appliance, traffic may never reach the NAT gateway. This surprises teams who remove the default route as part of a security hardening project and then wonder why NAT stopped working.

The lesson is that NAT is one stage in a chain. A packet must first be allowed by egress firewall rules, then matched to a route, and only then translated. When troubleshooting, walk the chain in order instead of looking only at the NAT page.

Simple Analogy

Even the best mailroom is useless if the road to the post office is closed. The route is the road, the firewall is the security gate, and NAT is the mailroom. All three must work for a letter to arrive.

7External IP Addresses: Automatic or Manual

The public addresses your gateway uses decide what the outside world sees, so this choice affects partners, allowlists, and scaling.

Automatic allocation

In automatic mode, Google Cloud assigns and manages the external addresses for the gateway. Google’s documentation says Cloud NAT can automatically scale the number of NAT addresses it uses as more machines or more connections need them. This is the easiest option. You do not reserve anything, you do not watch for running out of addresses, and the gateway grows with the workload. The cost of that convenience is that the addresses are not under your control and can change as the gateway scales.

Manual allocation

In manual mode, you reserve specific static external addresses and give them to the gateway. Google notes that with manual assignment you can share a fixed set of external addresses with a destination party that allows only known addresses. This is common when your application calls a bank, a government service, a partner company, or a software vendor that protects its endpoints with an allowlist, which is a list of approved source addresses.

Simple Analogy

Automatic mode is like using whichever company phone happens to be free: easy, but the number on the caller display changes. Manual mode is like using one registered office line that the customer has saved as “approved”. The customer’s receptionist only picks up for that exact number.

AspectAutomaticManual
Who picks the addressesGoogle CloudYou reserve them
Scaling with demandGrows automaticallyYou must add addresses before running out
Partner allowlistsAwkward, addresses can changeIdeal, addresses stay fixed
EffortLowestHigher, needs capacity planning

How many addresses do you need?

Each address offers roughly 64,000 usable ports. If your machines need many simultaneous connections to the same destination, you will need more addresses to supply enough distinct address and port pairs. A useful rule of thumb is to estimate peak concurrent connections per destination, multiply by the number of machines, and compare the result with the ports your gateway can offer. Add comfortable headroom, because running out causes dropped connections rather than slow ones.

!
Common Mistake

Using automatic mode while telling a partner to allowlist addresses. When the gateway scales or addresses change, the partner suddenly blocks you, and the outage looks like an application bug. If an allowlist is involved, use manual mode and tell the partner about spare addresses in advance.

i
Planning Tip

Reserve one or two more addresses than you think you need and get them allowlisted early. Adding an address later requires waiting on the partner’s change process, which is often slower than the cloud change itself.

Naming and documenting your addresses

Reserved addresses should carry clear names that say what they are for and which environment they belong to. A name such as “prod-eu-nat-1” tells a future engineer far more than an auto-generated label. Keep a simple record of which partners have allowlisted which addresses and when. When someone later wants to release an address, the record shows immediately whether doing so would break a partner connection.

8Ports, Dynamic Port Allocation, and Exhaustion

Ports are the currency of NAT. Running out of them is the most common production problem, and it is very preventable.

Static and dynamic port allocation

Cloud NAT can hand out ports to each machine in two ways. With static port allocation, every machine gets the same fixed number of ports, set by a minimum-ports-per-VM value. It is simple and predictable, but wasteful if some machines are busy and others are idle, because every machine holds its full share whether it uses it or not.

With dynamic port allocation, each machine starts with a smaller minimum and can receive more ports as its need grows, up to a maximum. Google’s tuning documentation states that the dynamic minimum must be a power of two between 32 and 32,768, and the maximum must be a power of two between 64 and 65,536, greater than the minimum, with 65,536 as the default maximum. This lets busy machines borrow capacity while quiet machines keep only a little.

Simple Analogy

Static allocation is a restaurant giving every table exactly ten menus, even for tables that never open them. Dynamic allocation hands out a few menus at first and brings more to any table that fills up, so the supply stretches much further.

SettingStatic allocationDynamic allocation
Ports per machineFixed minimum for everyoneStarts at a minimum, grows to a maximum
EfficiencyLower, idle machines hold unused portsHigher, ports follow demand
Tuning adviceSet the minimum to peak per-machine usageSet minimum below peak and maximum above peak
PredictabilityVery simple to reason aboutNeeds monitoring of real usage

Endpoint-independent mapping

Endpoint-independent mapping, often shortened to EIM, is a setting that changes how mappings are shared across destinations. Google’s documentation says it must be disabled before you can switch to dynamic port allocation. Some applications that depend on certain peer-to-peer or real-time behaviors want EIM, while most ordinary web workloads do not. Check what your applications really need before changing this setting.

What port exhaustion looks like

When a machine uses up all the ports assigned to it for a given destination, new connections to that destination cannot be created. Applications see failed connections, timeouts, or intermittent errors, often only at busy moments and often only toward one popular destination. Because other traffic keeps working, the problem is easy to misdiagnose as a flaky remote server.

flowchart TD
  A["Spike in outbound connections"] --> B{"Ports left for this VM and destination?"}
  B -- "Yes" --> C["New connection works"]
  B -- "No" --> D["Connection fails or is dropped"]
  D --> E["Application errors and retries"]
  E --> F["More connection attempts, worse shortage"]
        
FIG 5 — How port exhaustion can snowball

Notice the last two boxes. Applications that retry aggressively can make the shortage worse, because each retry tries to open yet another connection. Good clients reuse connections and slow down their retries.

How to fix it

  • Check the per-machine port usage metric over a representative period, such as the past thirty days, to find the true peak.
  • With static allocation, raise the minimum ports per machine to your measured peak.
  • With dynamic allocation, keep the minimum below the peak and the maximum above it.
  • Reduce the demand itself: reuse connections with keep-alive and connection pools, and avoid opening a new connection for every small request.
  • Add more external addresses when the total pool, not the per-machine share, is the limit.
!
Tuning Can Drop Connections

Google’s documentation warns that lowering the maximum ports per machine under dynamic allocation causes connections to be dropped, and lowering the minimum when dynamic allocation is off does too. Raising the minimum or changing timeouts does not. Make reductions carefully and during quiet periods.

A worked example of port math

Suppose a fleet of one hundred application servers sits behind a gateway. Each server needs about sixty-four simultaneous connections toward the busiest external service during normal hours, and about one thousand during the daily peak. With a static minimum of sixty-four, the fleet needs about six thousand four hundred ports in total, which fits easily within the roughly sixty-four thousand ports of a single address. At the peak, with one thousand per server, the same fleet needs one hundred thousand ports, which is more than one address can supply, so at least two addresses are required.

Now consider dynamic allocation with a low minimum and a high maximum. Servers start with a small share and grow only while they are busy. Because not every server peaks at the same moment, the total in use at any instant is lower than the sum of the individual maximums. The fleet may then get by with fewer addresses, but only if monitoring confirms the peaks really are staggered. Never assume. Measure the real usage across several busy periods before shrinking anything.

i
Rule of Thumb

Divide the usable ports on an address by the ports each machine needs to estimate how many machines one address can serve. Then keep a healthy safety margin, because growth, retries, and slow remote services all increase port use.

9Timeouts and Connection Behavior

NAT remembers every mapping for a limited time, and those timers decide how quickly ports come back and how long idle connections survive.

Why timers exist

A NAT table cannot remember every connection forever, or ports would never be freed. Each kind of mapping has an idle timeout. When a connection stays silent for longer than its timeout, the mapping disappears and the port returns to the pool. A longer timeout keeps quiet connections alive but holds ports for longer. A shorter timeout frees ports faster but may cut off connections that are only pausing.

Simple Analogy

Think of coat check tickets. If the cloakroom keeps your coat for only five minutes after you leave, the racks stay free, but late returners lose their coats. If it keeps coats for a week, the racks overflow. Timeouts are the cloakroom’s policy.

The timers and their defaults

TimerDefaultWhat it means
UDP mapping idle30 secondsHow long a silent UDP mapping survives. Raising it reduces port reuse.
TCP established idle1,200 secondsTwenty minutes for an open but quiet TCP connection. Raise it for long-lived idle connections.
TCP transitory idle30 secondsFor connections still opening or closing. Some extra time may pass before reuse.
TCP TIME_WAIT30 or 120 secondsWait after closing before reusing a port. Newer gateways default to 30 seconds.
ICMP mapping idle30 secondsFor ping-style traffic, in Public NAT only.

Google’s release notes announced that the default TCP TIME_WAIT timeout is decreasing from 120 seconds to 30 seconds, and the tuning page says gateways created after September 30, 2026 use 30 seconds by default. Older gateways may still have 120, so check the effective value on your own gateway. The documentation also advises setting at least 15 seconds to avoid dropped packets, and says timers can vary by up to five seconds, so it suggests adding five seconds to the value you intend.

Long-lived idle connections

The twenty-minute established timeout surprises many teams. A database connection pool that sits idle overnight, or a long-polling client, may be silently cut after twenty minutes of silence. The next use then fails with a confusing reset error. The cure is either to raise the timeout, or better, to enable keep-alive messages in the application so the connection never looks idle.

i
Keep-Alive Tip

Set the application’s TCP keep-alive interval comfortably below the NAT idle timeout. Then the mapping is refreshed regularly and idle connections survive without needing a larger timeout.

!
Common Mistake

Raising every timeout to a very large number to “be safe”. Long timeouts hold ports for longer and make exhaustion more likely. Change the timer that matches the symptom, and measure before and after.

Choosing timers with evidence

Timer changes should follow evidence, not hunches. If connections to a database fail after long quiet periods, confirm that the quiet time exceeds the established timeout, and prefer keep-alive messages from the application. If ports are scarce, look at whether many connections are sitting in a closing state and consider the transitory and TIME_WAIT timers. If UDP-based services such as DNS or real-time media lose mappings, consider the UDP idle timeout. Change one timer at a time, observe the effect for a full business cycle, and write down the result.

10NAT Rules and Fine-Grained Control

NAT rules let one gateway behave differently for different traffic, for example by using particular addresses for particular destinations.

Why rules exist

A default gateway treats all matching traffic the same way. Real organizations have more specific needs. One partner may require traffic to come from a particular address. A compliance team may want regulated workloads to use a separate set of addresses so they can be audited. A rule lets you say “when traffic matches this condition, use these addresses instead”. Without rules you would need to build separate networks or gateways for each special case.

Simple Analogy

Rules are like special instructions to the mailroom: “Letters to the tax office go out with the finance department’s return address, and everything else uses the company’s usual one.” The mailroom still handles all the mail, but follows the special instructions when they match.

Destination and source based rules

NAT rules traditionally match on the destination of the traffic. Google’s release notes also describe source-based NAT rules for IPv4. These became generally available for Public NAT in April 2026, after a preview that began in September 2025, and entered preview for Private NAT in September 2026. Source-based rules help when different workloads inside the same subnet should use different outbound addresses.

Rule Use 1

Partner Allowlisting

Send traffic to one partner through a small, fixed set of addresses so the partner’s allowlist stays short and stable.

Rule Use 2

Workload Separation

Give a sensitive workload its own outbound addresses so its traffic is easy to identify and audit.

Rule Use 3

Capacity Isolation

Keep a noisy workload on its own addresses so it cannot use up ports needed by critical services.

Rule Use 4

Migration Support

Move traffic gradually to new addresses by shifting one destination at a time and watching for problems.

i
Keep Rules Readable

Name rules by purpose and keep a short document explaining why each exists. Rules that nobody remembers become traps during the next network change.

!
Common Mistake

Creating many overlapping rules without testing which one matches first. Always verify with test traffic that the expected addresses are used, and confirm the current rule limits and status of features in the documentation before depending on them.

Testing rules safely

Because a rule changes which addresses outsiders see, a mistake can cut off a partner or leak traffic from an unexpected address. Test rules first in a non-production environment that mimics the real layout. Send test connections from workloads that should match, and from workloads that should not, and confirm that each uses the intended addresses. Then roll the rule out gradually, starting with a small, low-risk workload, and keep the old behavior ready to restore.

11Which Workloads Can Use Cloud NAT

Cloud NAT serves virtual machines, containers, and several serverless products, each connecting in its own way.

Compute Engine Virtual Machines

The simplest case. A machine without an external address in a covered subnet gets outbound internet access automatically. Managed instance groups and autoscaling work without extra setup.

Google Kubernetes Engine

Private clusters have nodes with no external addresses, so pods cannot reach the internet by themselves. Cloud NAT gives nodes and pods outbound access to pull images from outside registries, call external APIs, and install packages. Pod traffic usually shares the node’s NAT allocation, so busy clusters need careful port planning.

Cloud Run and Cloud Run Functions

Serverless services that must reach the internet from a fixed address can send traffic through a VPC network. Google’s documentation says Cloud Run services, jobs, and Cloud Run functions use Direct VPC egress, which it recommends, or Serverless VPC Access. Once traffic enters the VPC, Cloud NAT translates it. Private NAT support for Cloud Run became generally available in October 2025.

App Engine Standard

App Engine standard instances use Serverless VPC Access to enter the VPC and then use Cloud NAT for outbound traffic toward destinations that require a stable source address.

Regional Internet Network Endpoint Groups

Cloud NAT also supports translation for regional internet NEGs, which let load balancers send traffic to external backends. This helps when a load balancer forwards to destinations outside Google Cloud.

flowchart LR
  VM["Compute Engine VMs"] --> NAT["Cloud NAT gateway"]
  GKE["GKE private nodes and pods"] --> NAT
  RUN["Cloud Run with Direct VPC egress"] --> NAT
  GAE["App Engine with Serverless VPC Access"] --> NAT
  NAT --> NET["Internet or private destinations"]
        
FIG 6 — Many kinds of workloads sharing one NAT service
Simple Analogy

Different departments, such as the factory floor, the call center, and the remote contractors, all send their mail through one company mailroom. They reach it by different doors, but once inside, the same stamping rules apply.

!
Check Before You Plan

Support details, such as which resource types work with Public NAT versus Private NAT, change over time. Confirm the current support table in the documentation before you design around a specific combination.

Special notes for container and serverless workloads

Containers and serverless platforms start and stop quickly, which makes their NAT usage spiky. A cluster that scales from ten to a hundred nodes in minutes can suddenly need many more ports and addresses. Plan for the largest scale the autoscaler allows, not today’s size. For serverless services, remember that every instance that starts may open fresh connections, so connection reuse inside each instance and sensible limits on concurrency help protect the shared pool.

12Security and Governance

Cloud NAT supports a secure design, but it is only one layer. Firewalls, identity, and egress controls do the real policing.

What NAT does for security

Cloud NAT helps security by making it possible to run machines without public addresses. Those machines cannot be reached directly from the internet, which shrinks the attack surface. Because Cloud NAT accepts only replies to connections that started inside, scanning the NAT address from outside finds nothing to attack on your private machines.

What NAT does not do

NAT does not inspect content, does not block malware, and does not stop a compromised machine from sending data out. If an attacker controls a private machine, NAT happily carries their outbound traffic to the internet like any other. That is why egress control matters just as much as ingress control.

Simple Analogy

A mailroom that delivers only replies keeps strangers from walking in. But if a dishonest employee mails confidential documents to a competitor, the mailroom will still stamp and send them. You need a policy about what may leave, not only what may enter.

Control 1

Egress Firewall Rules

Allow only the destinations and ports your workloads truly need. Deny everything else by default.

Control 2

Least-Privilege IAM

Limit who can change gateways, addresses, and routers. A wrong change can cut off an entire environment.

Control 3

Logging for Audit

Keep NAT logs so you can answer which machine connected to which destination at a given time.

Control 4

Inspection and Proxies

For deep inspection or content filtering, add a firewall appliance or secure web proxy in the path. NAT alone cannot do it.

Control 5

Private Google Access

Reach Google APIs over Google’s internal network instead of the internet, which keeps that traffic off your NAT addresses.

Control 6

Change Management

Treat gateway and address changes as production changes, with review, testing, and a rollback plan.

Auditing who talked to whom

Because many machines share a few public addresses, the outside world cannot tell them apart. If a partner reports suspicious activity from your address, you need your own records to find the exact machine. NAT logs include the private source, the translated address and port, and the destination, which lets security teams trace an event back to one workload. Without logs, the shared address is a dead end.

!
Common Mistake

Treating NAT as the whole security story. A private subnet with open egress and no logging is only hidden, not protected. Pair NAT with egress rules, monitoring, and sensible identity controls.

Who owns the gateway?

In larger companies, a central network team often owns gateways and address pools, while application teams own the workloads that use them. This split works well when it is written down. The network team promises a stable set of outbound addresses and healthy capacity. Application teams promise to reuse connections, tell the network team about new destinations, and respond to port alerts. Without a clear agreement, each side assumes the other is watching, and a shortage is discovered only by customers.

A shared responsibility note should say who can change settings, who is paged for alerts, how partners are informed about address changes, and how long advance notice is needed. A one-page document like this prevents more outages than any technical tweak.

13Logging, Monitoring, and Troubleshooting

Good visibility turns a mysterious outage into a five-minute diagnosis.

Logs

Google says Cloud NAT logs can trace connections and bandwidth, which supports compliance, debugging, analytics, and accounting. Logging can usually be set to record only errors, only successful translations, or everything. Recording everything is the most informative but also the most voluminous, and it adds logging cost on busy gateways. Many teams record errors permanently and turn on full logging temporarily during investigations.

Metrics

Metrics flow automatically into Cloud Monitoring, so you can build dashboards and alerts without installing anything. The documentation also mentions that Network Analyzer publishes Cloud NAT insights, which can point out configuration problems. The metrics below deserve a place on every NAT dashboard.

SignalWhat it tells youAction to consider
Port usage per VMHow close each machine is to its port limitRaise ports or reduce connection churn
Dropped sent packetsOutgoing packets that could not be translatedLook for exhaustion or missing coverage
Allocation failuresMachines that could not get ports or addressesAdd addresses or adjust allocation
Sent and received bytesHow much traffic passes throughSpot unusual spikes or data leaks
Open connectionsCurrent number of tracked connectionsCheck for leaks and timeout issues
Simple Analogy

Port usage is like watching how many of your parking spaces are full. You do not need an alarm when the lot is half empty, but you very much want one when it hits ninety percent, before cars start circling and blocking the road.

A simple troubleshooting routine

1

Check coverage

Is the machine’s subnet served by a gateway, and does the machine lack its own external address?

2

Check firewall and routes

An egress rule or missing route can block traffic before NAT ever sees it.

3

Check ports

Look at port usage and dropped packet metrics, especially toward one popular destination.

4

Check timers

Intermittent resets after long idle periods usually point to the established-connection timeout.

5

Check the destination

Confirm the remote side allows your NAT addresses and is not rate limiting you.

i
Test From Inside

Ask a small test machine in the same subnet to contact a service that reports the caller’s address. This quickly confirms which public address the outside world sees and proves the allowlist is correct.

Building a useful dashboard

A good NAT dashboard answers four questions at a glance. Are any machines close to their port limits? Are packets being dropped? Is traffic volume normal compared with the same hour last week? Which destinations receive the most connections? Put these four views on one page, label thresholds clearly, and link the page from the alert messages so the person on call lands in the right place immediately.

14Design Patterns and Popular Use Cases

A handful of tried and tested layouts solve most NAT needs in the real world.

Private Application Tier with Outbound Access

Web traffic enters through a load balancer, application servers sit in private subnets without public addresses, and Cloud NAT lets those servers call external services and fetch updates. This is the most common pattern and the best starting point for new projects.

Private GKE Cluster with Controlled Egress

Nodes have no external addresses, the control plane is protected, and Cloud NAT provides the only route to external registries and APIs. Combined with egress firewall rules, the cluster can reach only approved destinations.

Stable Source Address for Partner Allowlists

A manual gateway with a small set of reserved addresses gives every outbound call a predictable source. The partner allowlists those addresses once, and your autoscaling fleet can grow behind them without further changes.

Fixed Egress for Serverless Workloads

A Cloud Run service routes outbound traffic into a VPC through Direct VPC egress, and Cloud NAT gives it a stable public address. This solves the old problem that serverless products often call out from changing addresses.

Overlapping Address Ranges with Private NAT

After a company merger, two networks both use the same private ranges. Private NAT translates one side into unique addresses from a dedicated range, so connectivity works without a risky renumbering project.

Hybrid Connectivity to On-Premises Systems

Cloud workloads reach a legacy datacenter over Cloud VPN or Cloud Interconnect. Hybrid NAT presents cloud traffic to the datacenter using a small, agreed range, which eases firewall changes on the datacenter side.

IPv6 Workloads Reaching IPv4 Services

IPv6-only workloads use NAT64 to reach destinations that only speak IPv4. This lets teams adopt IPv6 earlier without waiting for the whole internet to catch up.

flowchart TD
  USER["Internet users"] --> LB["Load balancer"]
  LB --> APP["App servers in private subnet"]
  APP --> DB["Database in private subnet"]
  APP --> NAT["Cloud NAT gateway"]
  NAT --> EXT["External APIs and update servers"]
  APP --> PGA["Google APIs through Private Google Access"]
        
FIG 7 — The classic private application tier with Cloud NAT

This layout separates the two directions of traffic cleanly. Inbound user requests use the load balancer. Outbound calls use Cloud NAT. Calls to Google services use Private Google Access. Each road has its own owner, and each can be monitored on its own.

Multi-region and shared-network designs

Many organizations run several regions for resilience or to be near customers. Each region needs its own Cloud Router and gateway, and each gateway has its own addresses. A partner that allowlists addresses must therefore receive the lists for every region you operate in. If a region fails and traffic moves to another, the partner will see a different set of source addresses, so plan allowlists for failover regions in advance rather than during an emergency.

In shared network designs, where many projects use one central network, it is usual for the central team to own the NAT configuration. This keeps outbound addresses consistent across all teams and makes auditing simpler. In designs with many separate networks, standardizing the gateway settings through infrastructure code keeps behavior consistent and reduces surprises when engineers move between teams.

!
Failover Reminder

A disaster recovery plan that forgets outbound addresses fails in a subtle way. The application starts in the backup region, but a partner blocks its unfamiliar addresses. Include NAT addresses in every failover test.

“Inbound traffic needs a front door, outbound traffic needs a mailroom, and mixing the two up is where most network confusion begins.”

15Anti-Patterns to Avoid

Most Cloud NAT incidents come from a short list of repeated design mistakes.

ANTI-PATTERN-01 Avoid
Problem

Teams give every virtual machine its own external address “just to make things work”, skipping NAT entirely.

Why It’s Harmful

Every machine becomes directly reachable from the internet, widening the attack surface. Outbound addresses are scattered, so partner allowlists become unmanageable and audits become painful.

Correct Approach

Keep workloads private and give them controlled outbound access through Cloud NAT, with firewall rules to limit what can leave.

ANTI-PATTERN-02 Avoid
Problem

The gateway uses automatic address allocation while a partner holds an allowlist of specific source addresses.

Why It’s Harmful

When addresses change or scale, the partner blocks the new ones and calls start failing, often late at night and with unclear symptoms.

Correct Approach

Use manual allocation with reserved addresses, allowlist all of them, and keep spare addresses ready before they are needed.

ANTI-PATTERN-03 Avoid
Problem

Nobody watches port usage. The default settings run unchanged until a traffic spike causes mysterious connection failures.

Why It’s Harmful

Port exhaustion looks like a flaky remote service. Engineers waste hours blaming the wrong team while customers see errors.

Correct Approach

Track per-machine port usage and dropped packets, alert before limits are reached, and tune ports using measured peaks.

ANTI-PATTERN-04 Avoid
Problem

Applications open a brand-new connection for every small request and close it afterwards.

Why It’s Harmful

Every connection consumes a NAT port, and closed ports wait before being reused. High request rates burn through ports even when the actual data volume is small.

Correct Approach

Reuse connections with keep-alive and connection pools, so many requests share a few connections.

ANTI-PATTERN-05 Avoid
Problem

Someone expects Cloud NAT to deliver inbound connections to private servers, such as making a private web server reachable from the internet.

Why It’s Harmful

Cloud NAT only translates replies to connections that started inside. The server stays unreachable, and teams are tempted to add public addresses as a rushed workaround.

Correct Approach

Use a load balancer or another proper inbound entry point for incoming traffic, and keep Cloud NAT strictly for outbound needs.

ANTI-PATTERN-06 Avoid
Problem

All environments, production and testing, share one gateway and one address pool with no separation.

Why It’s Harmful

A load test can use up the ports production needs. A partner cannot distinguish test traffic from real traffic, and logs become hard to interpret.

Correct Approach

Separate environments with their own networks or at least their own rules and address sets, so mistakes stay contained.

Why these mistakes are so common

These anti-patterns spread because they work in small environments. With a handful of machines and a few connections, default settings never run out of ports, automatic addresses never cause allowlist problems, and unlogged traffic never needs an audit. The trouble appears only when the system grows, and by then the habits are everywhere. Reviewing designs early, while they are small, is much cheaper than fixing them at scale.

16Best Practices and Common Mistakes

A short checklist of habits separates calm Cloud NAT operations from stressful ones.

Habits that pay off

1

Make workloads private by default

Give machines external addresses only when there is a clear reason, and prefer NAT plus a load balancer for the rest.

2

Create a gateway in every region you use

Gateways are regional, so each region with private workloads needs its own coverage.

3

Pick allocation mode on purpose

Automatic for simplicity, manual whenever outsiders rely on your addresses.

4

Consider dynamic port allocation

It spreads ports according to real demand and reduces waste, as long as your applications do not need endpoint-independent mapping.

5

Set up alerts before launch

Alert on rising port usage and dropped packets so you learn about trouble from a dashboard, not a customer.

6

Teach applications to reuse connections

Use pools, keep-alive, and polite retries with growing pauses. This is cheaper than any amount of extra addresses.

7

Manage everything as code

Keep gateway, address, and rule definitions in version control, with review and tests, so changes are traceable and reversible.

Mistakes that appear again and again

Mistake 1

Forgetting a region

A workload launched in a new region has no outbound access because nobody created a gateway there.

Mistake 2

Ignoring the idle timeout

Long-idle database or messaging connections are cut after the established timeout, causing odd errors after quiet periods.

Mistake 3

Blaming the remote service

Intermittent failures toward one destination are often NAT port limits on your side, not a problem at the destination.

Mistake 4

Changing ports during peak hours

Reducing port settings can drop live connections. Plan reductions for quiet windows and rehearse in staging.

Mistake 5

No egress rules

Allowing all outbound traffic makes it easy for compromised machines to send data anywhere.

Mistake 6

Skipping logs for cost reasons

Turning off all logs saves a little money and costs a great deal of investigation time later. Keep at least error logging.

i
Pre-Launch Checklist

Before a new environment goes live, confirm that the gateway covers the right subnets, the public address seen by partners is correct, logs and alerts are on, and a test machine can reach each required destination.

A small runbook for on-call engineers

When an alert fires at night, people think poorly and need a short, clear guide. A good Cloud NAT runbook lists the symptom, the first three things to check, and the safe actions. For a port usage alert, the guide might say: identify the busiest machines, identify the busiest destination, check whether a recent release changed connection behavior, and consider raising the minimum ports or adding an address if the pool is the limit. It should also list actions that are not safe, such as lowering port settings during peak traffic, because those can drop live connections.

Keep the runbook near the alert itself, update it after each incident, and rehearse it occasionally. Teams that practice recover faster, and new engineers gain confidence sooner.

17Advantages, Trade-offs, and Cost Thinking

Cloud NAT removes a lot of operational work, but it comes with limits and costs worth understanding.

Advantages

  • Fully managed, with no appliances to patch, size, or restart.
  • Distributed design that does not reduce per-machine network bandwidth.
  • Lets workloads stay private while still reaching what they need.
  • Scales automatically with autoscaling groups and with automatic address allocation.
  • Stable, shareable outbound addresses for partner allowlists.
  • Built-in logging and Cloud Monitoring metrics.

Disadvantages / Trade-offs

  • Outbound only: it does not make private machines reachable from outside.
  • Ports are a finite resource, so heavy connection use needs planning.
  • No content inspection, malware blocking, or data loss prevention.
  • Regional, so multi-region setups need several gateways.
  • Many machines share addresses, so tracing activity needs logs.
  • Costs grow with usage, logging volume, and reserved addresses.

Cloud NAT compared with the alternatives

OptionHow it worksGood forWatch out for
Cloud NATManaged, distributed translationOutbound access for private workloadsPort planning, no inspection
External IP on each VMEach machine has its own public addressMachines that truly must be reachableExposure, scattered addresses
NAT appliance VMYou run your own translating machineSpecial features Cloud NAT lacksYou handle scaling, patching, and failure
Proxy or web gatewayTraffic goes through a filtering proxyContent filtering, URL policy, inspectionMore components and more cost

How the bill is built

Google prices Cloud NAT using a few components. There is a charge related to gateway usage per machine over time, a charge for the amount of data processed through the gateway, and separate charges for any external IP addresses you reserve and for logging volume. The details and rates change, so always read the current pricing page. What matters for design is the shape of the cost: it grows with the number of machines using the gateway, with outbound data volume, and with the number of reserved addresses.

Simple Analogy

Using a courier service has a similar bill. You pay for the account and for each package weight, and extra for a dedicated return address. Reducing unnecessary packages saves more than haggling over the rate.

i
Cost Tip

Send Google API traffic through Private Google Access instead of the NAT path, cache large downloads inside your network, and avoid pulling the same big files from the internet repeatedly. These steps cut both data cost and port pressure.

Budgeting a gateway sensibly

Cost planning for Cloud NAT is easier when you separate the fixed and the variable parts. Reserved addresses and the number of machines using the gateway are mostly predictable. Data processed and log volume vary with traffic. A healthy habit is to review the data processed each month, identify the biggest senders, and ask whether their traffic could take a cheaper path, such as Private Google Access for Google services, a regional cache for downloads, or a smaller log setting for chatty gateways.

Also remember the hidden cost of outages. A few extra reserved addresses and some monitoring are cheap compared with an hour of failed calls to a payment provider. Spend on prevention where the business impact is highest, and be frugal where traffic is harmless.

18Real-World Scenarios

Walking through realistic situations shows how the ideas fit together.

The Payment Partner That Wants an Allowlist

An online store must call a payment provider that accepts requests only from approved addresses. The team reserves three static addresses, assigns them to a manual gateway, and sends the provider the list. When Black Friday traffic doubles, the fleet autoscales, yet every call still leaves from the same three addresses. Because the team also set port alerts, they added a fourth address a week earlier, after tests showed the pool would be tight.

The Mystery of Failing Calls at Noon

A reporting service fails to reach a popular external API every day around noon, but only some calls. The remote provider insists nothing is wrong. Dashboards show one machine hitting its port limit toward that single destination, because the service opens a new connection for every request. Adding connection reuse in the application solves the problem without touching NAT settings at all.

The Merger with Overlapping Networks

Two companies join together, and both internal networks use the same private address ranges. Renumbering would take a year. The cloud team uses Private NAT to translate one side into unique addresses taken from a dedicated range, and applications start communicating within weeks, giving time to renumber gradually.

The Private Cluster That Could Not Pull Images

A team creates a private GKE cluster for compliance reasons and finds pods stuck waiting to pull a third-party container image. Nodes have no external addresses and no gateway covers their subnet. Creating a Cloud NAT gateway for the cluster subnet fixes it, after which the team adds egress rules to allow only the registries they actually use.

The Serverless Service with a Fixed Address

A Cloud Run service must call a legacy system that only accepts known sources. The team routes the service’s outbound traffic through a VPC using Direct VPC egress, attaches a Cloud NAT gateway with a reserved address, and gives the legacy team that single address.

Allowlists
need manual, fixed addresses
Spikes
need port headroom and monitoring
Mergers
need Private NAT for overlapping ranges
Simple Analogy

Each story is the same mailroom handling a different kind of mail. Sometimes the problem is the return address, sometimes the number of envelopes, and sometimes two offices that use the same room numbers. Knowing the mailroom’s rules tells you quickly which problem you have.

The Audit That Needed an Answer

A partner reports unusual requests from one of the company’s public addresses. Dozens of services share that address, so nobody can tell which one is responsible. Because the team kept NAT logs, they search for the partner’s destination and the time window, and find a single batch job using an outdated credential. They fix it within the hour. Without logs, the investigation would have stalled.

19Frequently Asked Questions

Quick answers to the questions that come up most often.

Q1Is Cloud NAT a virtual machine or a hardware appliance?

Neither. It is a distributed, software-defined managed service built on Google’s Andromeda network virtualization. You configure it, but you never size, patch, or restart a machine for it.

Q2Can the internet start a connection to my private machines through Cloud NAT?

No. Cloud NAT translates only established inbound response packets. For inbound traffic, use a load balancer or another appropriate entry point.

Q3Why can’t my private machine reach the internet?

The usual causes are no gateway covering its subnet, a firewall egress rule blocking the traffic, a missing route, or exhausted ports. Check coverage first, then firewall rules, then port metrics.

Q4Does Cloud NAT work for machines that already have an external IP?

Those machines use their own external address for internet traffic, so their connections do not use NAT ports.

Q5Do calls to Google APIs use my NAT addresses?

Not when Private Google Access is in use. Google’s documentation says traffic to Google APIs and services goes through Private Google Access even when Public NAT exists.

Q6What is port exhaustion and how do I prevent it?

It happens when a machine uses all the ports assigned to it, so new connections to a destination fail. Prevent it by monitoring port usage, using dynamic port allocation or higher minimums, reusing connections, and adding addresses when needed.

Q7Should I use automatic or manual address allocation?

Use automatic for simplicity when nobody depends on your addresses. Use manual when a partner or system uses an allowlist, because the addresses stay fixed.

Q8Why do idle connections break after about twenty minutes?

The default established TCP idle timeout is 1,200 seconds. Enable keep-alive in your application or raise the timeout if long idle periods are normal.

Q9What is the difference between Public NAT and Private NAT?

Public NAT lets private resources reach internet destinations using shared external addresses. Private NAT translates traffic between private networks, which helps with overlapping ranges, hybrid connections, and NAT64.

Q10Is one gateway enough for a multi-region application?

No. Gateways are regional, so you create one in each region that has private workloads needing outbound access.

Q11Does Cloud NAT slow down my machines?

Google states that Cloud NAT does not reduce the network bandwidth per machine, because the translation is distributed rather than funneled through one device.

Q12Can Cloud NAT help with IPv6?

Yes. NAT64 translates IPv6 traffic to IPv4 destinations. Google’s release notes list it as generally available for Public NAT since August 2025 and for Private NAT since October 2026.

Q13How do I find which machine made a certain connection?

Use Cloud NAT logs. They record the private source, the translated address and port, and the destination, so you can trace shared-address traffic back to one workload.

20Summary and Key Takeaways

Cloud NAT is the quiet mailroom of your Google Cloud network. It lets private workloads reach the internet and other networks without public addresses, shares a limited pool of addresses and ports among many machines, and refuses to deliver anything nobody asked for. Success with it depends less on clever settings than on good habits: private workloads by default, deliberate address choices, port monitoring, connection reuse, sensible timers, and egress controls that decide what may leave.

Key Takeaways

  • Cloud NAT is outbound translation — it translates traffic that starts inside and established replies only, so private resources stay unreachable from outside.
  • It is managed and distributed — no proxy VMs or appliances, built on Google’s software-defined networking, configured on a Cloud Router in each region.
  • Choose the right type — Public NAT reaches the internet, while Private NAT handles overlapping ranges, hybrid networks, and NAT64.
  • Pick address mode by need — automatic for simplicity, manual with reserved addresses whenever partners rely on allowlists.
  • Ports are the real limit — monitor per-machine usage, consider dynamic port allocation, reuse connections, and add addresses when the pool is short.
  • Mind the timers — the twenty-minute established timeout and the TIME_WAIT default explain many odd resets and slow port recovery.
  • NAT is not a firewall — combine it with egress rules, least-privilege access, logging, and monitoring for real security.