Skip to Content

Internet gateway and route tables

The internet gateway that gives a VPC internet access, route tables and the local route, and what makes a subnet public.

Internet gateway (IGW)

An internet gateway allows resources (such as EC2 instances) in a VPC to connect to the internet.

  • It scales horizontally and is highly available and redundant: there's nothing to size.
  • It must be created separately from a VPC.
  • One VPC can only be attached to one IGW, and vice versa.
  • Internet gateways on their own don't allow internet access… route tables must also be edited.

Route tables

Internet gateway and route tables: the public subnet's route table sends 10.0.0.0/16 locally and 0.0.0.0/0 to the internet gateway, so its instances reach the internet; the private subnet's route table has only the local route Internet gateway and route tables: the public subnet's route table sends 10.0.0.0/16 locally and 0.0.0.0/0 to the internet gateway, so its instances reach the internet; the private subnet's route table has only the local route

A route to the IGW is what makes a subnet public.
  • A route table decides where traffic from a subnet goes. Each subnet is associated with one route table (the VPC's main route table if none is chosen).
  • Every route table has the local route (the VPC CIDR → local), so all subnets in a VPC can reach each other.
  • Public subnet: add 0.0.0.0/0 → igw-… (and ::/0 for IPv6).
  • Private subnet: no route to the IGW (usually 0.0.0.0/0 → nat-… for outbound access, see NAT).
  • Instances in the public subnet also need a public IPv4 (auto-assigned or an Elastic IP) to talk to the internet.
  • The most specific route wins: 10.0.1.0/24 beats 10.0.0.0/16.

Real-world examples

  • A web tier in public subnets with a route to the IGW, and an app tier in private subnets with only the local route and a route to a NAT gateway.

Exam tips

  • "Instance in a public subnet can't reach the internet" → check the route 0.0.0.0/0 → IGW, a public IP, security groups and NACLs.
  • "Make a subnet public" → route table with 0.0.0.0/0 to an internet gateway.

Common traps

  • "Attaching an IGW makes every subnet public." Only subnets whose route table points to it.
  • "Attach two IGWs to a VPC." One per VPC.

Hands-on lab: make a subnet public

Goal: add an internet gateway and a public route table to the VPC from the previous lab.

Costs money

Internet gateways and route tables are free. If you launch a test instance, a t3.micro costs about $0.01 an hour plus about $0.005 an hour for its public IPv4 address. Use the same Region as before.

Create and attach the IGW

Internet gateways → Create: saa-igw, then Actions → Attach to VPC → saa-vpc.

Create the public route table

Route tables → Create: saa-public-rt in saa-vpc. Edit routes → Add route 0.0.0.0/0 → saa-igw. Subnet associations → saa-public-a.

Auto-assign public IPs

Select saa-public-a → Actions → Edit subnet settings → tick Enable auto-assign public IPv4 address.

Expected result: saa-public-a uses saa-public-rt with a route to the IGW; saa-private-a still uses the main route table with only the local route.

Clean up: delete the route table, detach and delete the IGW, then delete saa-vpc.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt