Lesson 3 of 4 Amazon VPC

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.

GatewayDirectionNotes
Internet gatewayTwo-wayOne per VPC; scaled and highly available; for public IPs in public subnets
NAT gatewayOutbound IPv4 onlyIn 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 gatewayOutbound IPv6 onlyIPv6 addresses are public, so no NAT
NAT instanceOutboundLegacy: self-managed EC2 with source/destination check disabled
Match the pairs

Gateways

Exam skills 1.2.1 · 4.4.1

Match each requirement with the gateway that meets it.

Log in to try this activity Interactive activities are free with an account.

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.

A highly available egress design with zonal NAT gateways. Each Availability Zone has its own NAT gateway in a public subnet, and each zone's private subnets route to the NAT gateway in the same zone, so losing one zone does not cut outbound access for the others. A free gateway endpoint carries S3 and DynamoDB traffic, so that traffic is not charged NAT data processing.
With a Regional NAT gateway instead, the private subnets need only one route, and the gateway expands across the zones automatically.
Scenario questions

NAT gateway design

Exam skills 4.4.1 · 4.4.3

Choose cost-effective and resilient NAT designs.

Log in to try this activity Interactive activities are free with an account.

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.

True or false

Egress and admin access

Exam skills 1.2.1 · 1.2.3

Check how egress and administrative access are controlled.

Log in to try this activity Interactive activities are free with an account.
Worked example

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.

ChangeEffect
Add gateway endpoints for S3 and DynamoDBThat traffic bypasses the NAT gateway; gateway endpoints are free
Keep the NAT gateway for software updates from the internetStill needed for other outbound traffic
One NAT gateway per AZAvoids 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.

Check yourself

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.