Internet, NAT, and Egress Gateways
Control how subnets reach the internet in each direction.
Internet, NAT, and Egress Gateways is a free AWS Security Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Controlling Connectivity
Subnets become public or private based on which gateways their traffic can reach. AWS provides several gateway types, each controlling a different direction of internet access. Understanding them lets you allow exactly the connectivity each tier needs and nothing more.
The Internet Gateway
An internet gateway (IGW) is a horizontally scaled, highly available component that allows two-way communication between a VPC and the internet. A subnet with a route to the IGW is public. Resources also need a public IP or Elastic IP to be reachable from the internet through it.
The NAT Gateway
A NAT (Network Address Translation) gateway lets private-subnet resources make outbound connections to the internet, for updates or API calls, while blocking inbound connections initiated from outside. It sits in a public subnet and gives private instances internet access without making them internet-reachable.
Outbound Only
The NAT gateway is the key to the private-but-connected pattern: instances can pull patches and call external APIs yet cannot be reached from the internet. This one-way egress is exactly what application and data tiers usually need, balancing functionality with isolation.
NAT High Availability
A NAT gateway lives in a single AZ. For resilience, deploy one NAT gateway per Availability Zone and route each AZ private subnets to their local NAT. This avoids a single point of failure and keeps traffic within the AZ, improving both reliability and cost.
The Egress-Only Gateway
For IPv6, the equivalent of NAT is the egress-only internet gateway. It permits outbound IPv6 traffic from private resources while preventing the internet from initiating inbound IPv6 connections. IPv6 addresses are globally routable, so this gateway provides the outbound-only protection NAT gives for IPv4.
VPC Endpoints Avoid the Internet
To reach AWS services without any internet path, use VPC endpoints. Gateway endpoints (for S3 and DynamoDB) and interface endpoints (PrivateLink) let private instances call AWS APIs over the AWS network. This keeps traffic private and can remove the need for a NAT gateway for AWS-only egress.
Reducing Egress Surface
Every outbound path is a potential exfiltration route. Prefer VPC endpoints over NAT-to-internet for AWS services, and pair NAT with AWS Network Firewall domain filtering when broad internet egress is required. Minimizing and inspecting egress is a core hardening principle.
Choosing the Right Gateway
Match the gateway to the need: IGW for public, two-way internet; NAT for private IPv4 outbound-only; egress-only IGW for private IPv6 outbound-only; VPC endpoints for private AWS-service access. Choosing correctly is a frequent exam scenario.
Cost and Security Together
NAT gateways incur hourly and data-processing charges, so routing AWS traffic through endpoints instead can cut cost and improve security at once. The most secure design is often also the leaner one: less internet exposure and fewer dollars spent moving traffic through NAT.
Bringing It Together
Gateways shape your VPC connectivity. Use an IGW only for the minimal public tier, NAT or egress-only IGW to give private tiers safe outbound access, and VPC endpoints to keep AWS traffic off the internet entirely. This controlled connectivity is central to a secure VPC.
Quick Check
Choose the right gateway.
Recap
An internet gateway gives public subnets two-way internet access; a NAT gateway gives private IPv4 subnets outbound-only access; an egress-only internet gateway does the same for IPv6. Deploy NAT per AZ for resilience. Use VPC endpoints (gateway and interface/PrivateLink) to reach AWS services privately, reducing both egress surface and NAT cost.
Frequently asked questions
Is the “Internet, NAT, and Egress Gateways” lesson free?
Yes — the full text of “Internet, NAT, and Egress Gateways” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “Internet, NAT, and Egress Gateways”?
Control how subnets reach the internet in each direction. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Security Academy?
No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Internet, NAT, and Egress Gateways” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Security Academy lesson?
Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Public and Private Subnet Design
- Internet, NAT, and Egress Gateways
- Route Tables as Security Controls
- Securing VPC Peering and Transit Gateway