Cloud NAT Port Allocation and Port Exhaustion for the Professional Cloud Network Engineer Exam

GCP Study Hub
November 9, 2026

Cloud NAT translates outbound connections using a limited pool of source ports on each NAT IP address. Each NAT IP address gives Cloud NAT 64,512 usable source ports, and a VM needs one source port for each simultaneous connection it opens to the same destination. The default allocation is 64 ports per VM. Together, those numbers decide how many NAT IP addresses a gateway needs, and they explain a failure pattern that shows up only under load. For the Professional Cloud Network Engineer exam, that means being able to do the arithmetic and to recognize the symptoms of a shortage.

The port math

The demand side is the number of VMs multiplied by the ports each VM needs, which is the number of simultaneous connections it opens to one destination. The supply side is the number of NAT IP addresses multiplied by 64,512. The gateway has enough capacity when supply is at least as large as demand.

Dividing 64,512 by the ports per VM gives the number of VMs one NAT IP address can serve. At the default of 64 ports per VM, one address serves 1,008 VMs. At 256 ports per VM, it serves 252. At 512 ports per VM, it serves 126. Each time the ports per VM double, the number of VMs each address can serve is cut in half.

As an illustration, 300 VMs that each open 1,024 simultaneous connections to the same destination need 307,200 ports. Four NAT IP addresses provide 258,048 ports, enough for only 252 of those VMs. Five addresses provide 322,560 ports, which covers all 300. Two consequences follow from this math:

  • Raising the ports per VM without adding NAT IP addresses makes a shortage worse, because each address then serves fewer VMs.
  • Leaving the default of 64 ports per VM in place falls far short when each VM needs hundreds of connections to one destination.

Manual and automatic NAT IP allocation

A gateway can get its NAT IP addresses in two ways, and both can meet the same demand.

  • Manual allocation. You reserve a specific set of external IP addresses for the gateway and set the minimum ports per VM. You are responsible for reserving enough addresses to cover the total demand.
  • Automatic allocation. Cloud NAT reserves and adds NAT IP addresses as VMs need them, as long as regional quota allows. Once the minimum ports per VM matches what the workload requires, the gateway adds addresses as demand grows, so no up-front address count is needed.

In either mode the minimum ports per VM has to reflect the actual number of simultaneous connections to one destination. With automatic allocation the address count follows from that setting, and with manual allocation it has to be calculated and reserved up front.

One Public NAT gateway per subnet range

A subnet's primary range can be served by only one Public NAT gateway in a given region and network. A second gateway for the same subnet is not allowed, so extra capacity has to come from the existing gateway, by adding NAT IP addresses or changing its port allocation settings.

Recognizing port exhaustion

Port exhaustion has a recognizable pattern. It appears when many connections to the same destination open at once, so a burst of parallel TCP sessions can use up the available source ports and the gateway starts dropping new connections. Lightweight checks such as ping keep succeeding at the same time, because they need almost no NAT mappings. Failures that come and go with load are the signature of a capacity limit.

Cloud NAT logging with errors included records each dropped connection along with its destination, which confirms the cause. Tools that analyze configuration fit this kind of problem poorly. A Connectivity Test checks the configured path at the moment you run it, so it would probably report the path as reachable and miss a shortage that only appears under load.

Fixing it

Once logging confirms exhaustion, the fix is to add NAT IP addresses or change the port allocation settings, such as raising the minimum ports per VM. Raising the minimum only helps if there are enough addresses behind it, so the port math above should be rechecked with the new value. Automatic allocation handles the address side on its own as long as quota allows. With manual allocation, the reserved address count has to grow with the per-VM setting.

For the Professional Cloud Network Engineer exam, keep the three numbers in mind (64,512 ports per address, 64 ports per VM by default, one port per simultaneous connection to the same destination) and work out the totals before choosing an answer.

Our Professional Cloud Network Engineer practice exams cover Cloud NAT port allocation alongside Cloud NAT logging and network troubleshooting, with detailed explanations that drill these distinctions.

Get tips and updates from GCP Study Hub

arrow