What Is a NAT Gateway? Choose an Egress Path and NAT Type for Private Resources
A NAT gateway is a managed network service that translates a private source address so a resource can initiate a connection to an external destination. AWS public NAT gateways let instances in private subnets reach the internet without assigning each instance a public IP, but they do not forward arbitrary connections initiated from the internet to those instances. To understand the difference, consider the NAT gateway together with routes, public addresses, and security rules.
A NAT gateway is a managed network service that translates a private source address so a resource can initiate a connection to an external destination. AWS public NAT gateways let instances in private subnets reach the internet without assigning each instance a public IP, but they do not forward arbitrary connections initiated from the internet to those instances. To understand the difference, consider the NAT gateway together with routes, public addresses, and security rules.
How does a NAT gateway change packet addresses?
NAT means Network Address Translation. An internal resource sends a packet using a private IP address, and the NAT gateway changes the connection’s source to the gateway’s address before forwarding it outside. When a response returns, the gateway uses connection state to restore the destination to the original resource’s private IP. The internal resource must therefore initiate the connection first; an external service cannot start an arbitrary new connection to a private resource behind the NAT gateway.
Assumed flow: Suppose an instance in a private subnet sends an HTTPS request to an operating-system update server. The instance’s route table sends the default route for internet destinations to a NAT gateway. The gateway translates the private source IP to its NAT address. For public NAT, the VPC’s internet gateway maps that address to the Elastic IP associated with the NAT gateway and sends the packet to the internet. The response follows the established connection state back to the instance. This scenario illustrates the mechanism; it is not a test performed in a real environment.
How do AWS public and private NAT gateways differ?
AWS offers public and private NAT gateway connectivity types. Both translate an instance’s private IPv4 source to the NAT gateway’s private IPv4 address, but their destinations and external address paths differ.
| Type | Main use | Placement and next path | Important boundary |
|---|---|---|---|
| Public NAT gateway | Outbound IPv4 connections from private subnets to the internet | Create it in a public subnet and associate an Elastic IP. The subnet’s route must lead to the VPC’s internet gateway. | The internet cannot initiate arbitrary connections to instances behind it. |
| Private NAT gateway | Outbound connections to other VPCs, on-premises networks, or other private networks | Route it through a Transit Gateway, Virtual Private Gateway, or another suitable private connection. Do not associate an Elastic IP. | If traffic from a private NAT gateway is routed to an internet gateway, the internet gateway drops it. |
When traffic reaches the internet through a public NAT gateway, the external destination sees the NAT gateway’s Elastic IP as the source. But if a public NAT gateway is used with a private connection such as Transit Gateway, the destination may see the NAT gateway’s private IP. Do not assume that “public” means the Elastic IP is the source on every route.
How do routes and subnets fit together?
A typical AWS public NAT design uses a NAT gateway in a public subnet and workloads in private subnets. First, the public subnet containing the NAT gateway needs a route to the internet gateway. Then the route table for a private workload subnet sends its default route for external destinations to the NAT gateway. The route from the instance to the NAT gateway and the route from the NAT gateway’s subnet to the internet gateway can be in different route tables.
**Define the egress destination.** Decide whether workloads need the whole internet, only particular external services, or only another private network. If the destinations are limited, consider narrower routes instead of a default route.
**Choose the NAT type and placement.** For internet egress, consider public NAT and an Elastic IP. For translation between private networks, consider private NAT and the route to the destination network. Include subnet availability zones and failure paths in the design.
**Check each route table.** Confirm that the public subnet containing the NAT gateway can reach the internet gateway and that the private subnet sends external-destination traffic to the NAT gateway. AWS’s example uses `0.0.0.0/0` from the private subnet to the NAT gateway.
**Review the return path and security rules.** Check security groups, network ACLs, and the destination service’s allow policy. NAT tracks connection state so responses can return; it does not guarantee that the destination permits the connection.
**Verify from the workload.** Connect from a private instance to the intended external service and check that the observed public source IP is the expected one. AWS documents testing internet connectivity from an instance in the private subnet after the NAT and routes are configured. Do not use an ICMP ping alone to infer that HTTP or HTTPS works; test with the application protocol you need.
Does a NAT gateway replace a firewall or an internet gateway?
NAT and firewalls have different jobs. NAT changes addresses and tracks connections; security groups, network ACLs, and firewalls decide which flows are allowed or blocked. Being behind a NAT gateway does not mean a private resource should be allowed to reach every outbound destination. Restrict egress security rules to the required destinations and ports.
A NAT gateway is also different from an internet gateway. In the AWS public NAT path, the private subnet’s default route points to the NAT gateway, while the route table for the public subnet that contains the NAT gateway points to the internet gateway. AWS can also use DNS64/NAT64 when an IPv6-only instance needs to connect to an IPv4-only destination. For outbound-only internet connectivity over IPv6, AWS provides a separate egress-only internet gateway. Do not assume IPv4 NAT works identically for IPv6.
How do NAT services differ across AWS, Google Cloud, and Azure?
All three services use address translation to support connectivity, but they are not identical resources with identical configuration. AWS NAT Gateway offers public and private types in an AWS VPC. Google Cloud’s Cloud NAT is a distributed software-defined service that does not rely on proxy VMs, and it offers Public NAT and Private NAT. Azure NAT Gateway is an outbound service associated with a subnet and requires a public IP address or prefix. In Azure, new outbound flows use NAT Gateway preferentially after association, but a user-defined route that directs the default route to a virtual appliance or virtual network gateway can take precedence over its internet path.
| Decision criterion | What to check |
|---|---|
| Must the workload accept new connections from the internet? | A NAT gateway generally is not for forwarding unsolicited inbound connections to resources behind it. For a public service, consider a public load balancer or another inbound design. |
| Is the destination the internet or a private network? | NAT types differ by destination in AWS and Google Cloud. Do not infer internet egress support from the word “NAT” alone. |
| Must destinations allow-list the source public IP? | Check how the provider assigns or reserves NAT public IPs and which source address is actually visible on the route in use. |
| How should failures and operations be divided? | Check each provider’s availability-zone and regional scope, billing units, logging and monitoring, and source-port or connection limits in its current documentation. |
Azure’s default outbound behavior has changed for new networks and API versions. Microsoft documents that, from March 31, 2026, new virtual networks default to private subnets and do not receive default outbound access. For an Azure deployment, verify the API version and subnet property in use as well as the documentation date.
What if the connection fails or the source IP is unexpected?
**A private instance cannot reach the internet:** Check whether the route table actually used by the instance’s subnet points to NAT and whether the NAT subnet has a path to the internet gateway.
**NAT is active but new connections fail:** Check the connectivity type and public address association, the NAT subnet route, egress security rules, and the destination service’s allow policy in that order.
**An external client cannot connect first to a private instance:** This is normal NAT behavior. If you need to serve a public endpoint, choose an appropriate inbound service design instead of opening the NAT path further.
**Cost or capacity is higher than expected:** Check resource runtime, processed data, traffic path, public IP use, and the provider’s source-port or connection limits separately against current documentation and billing records. This article does not give a fixed price.
Before changing a NAT route, identify the affected subnets and workloads and record their existing routes. After the change, verify an actual application connection and its source address from a workload that uses the route. If something breaks, restore the previous path and inspect the address, route, and security policy one at a time to narrow down the cause.
References
[AWS: NAT gateway types and address translation](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html)
[AWS: Private-subnet internet access scenarios and routing](https://docs.aws.amazon.com/vpc/latest/userguide/nat-gateway-scenarios.html)
[Google Cloud: Cloud NAT overview and Public/Private NAT](https://docs.cloud.google.com/nat/docs/overview)
[Azure: NAT Gateway overview and outbound connectivity](https://learn.microsoft.com/en-us/azure/nat-gateway/nat-overview)
[Azure: Create and associate a NAT Gateway with a subnet](https://learn.microsoft.com/en-us/azure/nat-gateway/manage-nat-gateway)