Controlling Internet Access with Internet and NAT Gateways
This lesson explains how instances reach the internet, and how to stop the internet from reaching them, a core design decision for every VPC.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish internet gateways, NAT gateways and egress-only internet gateways.
- Explain how gateway endpoints reduce NAT gateway cost.
- Describe how egress is controlled by domain and how admin access works without bastions.
Gateway options
A VPC reaches the internet through gateways, which differ in the direction of traffic they allow. An internet gateway allows traffic in both directions for resources with public IP addresses in public subnets. There is one per VPC, and it scales automatically and is highly available, so it is never a bottleneck or a single point of failure.
A NAT gateway lets resources in private subnets make outbound IPv4 connections, for example to download updates, while blocking connections initiated from the internet. It sits in a public subnet with an Elastic IP address and scales to high bandwidth. A classic NAT gateway is zonal: it lives in one Availability Zone, so a highly available design places one NAT gateway in each zone and routes each zone's private subnets to its own. Since November 2025, a NAT gateway can instead run in Regional mode, in which one gateway expands across the VPC's Availability Zones automatically and the private subnets need only one route to it. A private NAT gateway, without an Elastic IP, translates addresses between private networks instead; it is available only in zonal mode.
IPv6 addresses are globally unique and public, so IPv6 needs no address translation. An egress-only internet gateway gives IPv6 the same outbound-only behaviour that a NAT gateway gives IPv4. A NAT instance is a legacy, self-managed EC2 instance performing NAT, with its source/destination check disabled; it requires patching, scaling and failover by hand. The following table summarises the options.
| Gateway | Direction | Notes |
|---|---|---|
| Internet gateway | Two-way | One per VPC; scaled and highly available; for public IPs in public subnets |
| NAT gateway | Outbound IPv4 only | In a public subnet with an Elastic IP; managed, up to 100 Gbps; zonal (one per AZ) or Regional (one gateway across AZs). Private NAT gateways translate between private networks |
| Egress-only internet gateway | Outbound IPv6 only | IPv6 addresses are public, so no NAT |
| NAT instance | Outbound | Legacy: self-managed EC2 with source/destination check disabled |
Gateways
NAT gateway cost
NAT gateways are charged per hour and per gigabyte of data processed, and the data processing charge adds up quickly when instances in private subnets read and write large amounts of data in Amazon S3 or DynamoDB through them. Gateway endpoints for S3 and DynamoDB, which are free, remove that path entirely, so this traffic no longer passes through the NAT gateway.
For high availability, production designs either place one zonal NAT gateway in each Availability Zone, so that the loss of one zone does not cut outbound access for the others, or use a Regional NAT gateway. In non-production environments, a single NAT gateway may be acceptable, accepting that an outage of its Availability Zone would affect the others.
The following diagram shows one zonal NAT gateway per Availability Zone and a gateway endpoint.

NAT gateway design
Controlling egress and admin access
Security groups and network ACLs filter traffic only by IP address and port. To allow outbound traffic only to approved domain names, such as a list of software repositories, egress is routed through AWS Network Firewall, whose stateful rules can match domain names, or through a proxy.
Administrative access to private instances no longer needs bastion hosts, which are servers in public subnets used as jump points. AWS Systems Manager Session Manager and EC2 Instance Connect Endpoint provide shell access with no public IP addresses and no inbound ports, with access controlled by IAM and sessions logged for audit.
Egress and admin access
A NAT gateway bill
A company's NAT gateway charges are high. VPC Flow Logs show that most of the traffic through it is private instances downloading data from S3 and writing to DynamoDB.
| Change | Effect |
|---|---|
| Add gateway endpoints for S3 and DynamoDB | That traffic bypasses the NAT gateway; gateway endpoints are free |
| Keep the NAT gateway for software updates from the internet | Still needed for other outbound traffic |
| One NAT gateway per AZ | Avoids cross-AZ charges and survives an AZ failure |
NAT gateways charge per hour and per GB processed, so moving AWS-bound traffic to endpoints is one of the easiest network savings. Instances that need only IPv6 outbound access can use an egress-only internet gateway instead.
How can instances with IPv6 addresses reach the internet without being reachable from it?
Show answer
Through an egress-only internet gateway, the IPv6 equivalent of a NAT gateway.
Exam Tips
Remember for the exam
- When private instances need outbound internet access, use a NAT gateway in a public subnet.
- For outbound-only IPv6 access, use an egress-only internet gateway.
- With zonal NAT gateways, use one per Availability Zone to avoid a single point of failure and cross-zone charges; a Regional NAT gateway spans zones automatically.
- For a remote shell to private instances without bastions, use Session Manager.
- To restrict outbound internet access to approved domains, use AWS Network Firewall.
- To reduce NAT data processing charges for S3, use a gateway endpoint.