Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
VPC — Your Private Network  ›  Lesson

Route Tables and the Internet Gateway

Route Tables 14 minA route table lists destinations and targets for a subnet's traffic, the most specific matching route wins, and a route to an internet gateway is what connects a subnet to the internet.

Route Tables and the Internet Gateway

A web server in Inkwell's public subnet sends two packets: one to the database next door, one to a payment provider on the internet. Nothing about the packets says "inside" or "outside". A small table attached to the subnet makes that decision for every packet, many times a second.

The rule

Most specific route wins; local is always there.

A route table is a list of rules, each with a destination (a CIDR block) and a target (where to send matching traffic). Every subnet is associated with exactly one route table; a subnet you do not associate explicitly uses the VPC's main route table. One route table can serve many subnets.

Inkwell's public route table:

Destination      Target
10.0.0.0/16      local
0.0.0.0/0        igw-inkwell
  • The local route covers the whole VPC. AWS adds it to every route table automatically and it cannot be deleted, so subnets in a VPC can always reach each other (security groups still decide what is allowed).
  • 0.0.0.0/0 means "any IPv4 address". Here it points to the internet gateway.

An internet gateway is the VPC's door to the internet. You create it, attach it to the VPC (one per VPC), and route to it. AWS runs it as a highly available, horizontally scaled service, so it is not a bottleneck and is not tied to one zone. The gateway also translates between an instance's private address and its public IPv4 address.

When a packet matches several routes, the one with the longest prefix, the biggest number after the slash, wins.

The shortcut

For each packet: list every route whose block contains the destination, then pick the biggest slash.

Tracing Inkwell's two packetsStep 1 of 4
  1. Packet to 10.0.11.20

    It sits inside 10.0.0.0/16 and inside 0.0.0.0/0. Two matches.

The trap: creating an internet gateway and attaching it, then wondering why nothing reaches the internet. Attaching is not enough; a subnet's route table needs the 0.0.0.0/0 route pointing to it.

Drills

Answer fast — trust the rule.

quick drill

A route table has 10.0.0.0/16 → local and 0.0.0.0/0 → igw. Where does a packet for 10.0.2.8 go?

quick drill

What does the destination 0.0.0.0/0 mean?

quick drill

Inkwell attached an internet gateway, but instances in a subnet still cannot reach the internet. What is the most likely missing piece?

quick drill

A subnet is not explicitly associated with any route table. Which one does it use?

Remember

  • Most specific route wins; the local route is always there.
  • Shortcut: list the matching routes, pick the biggest slash.
  • Trap: an attached internet gateway does nothing until a route points to it.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainTrace two packets

Inkwell's public route table has two routes: 10.0.0.0/16 to local, and 0.0.0.0/0 to igw-inkwell. Trace where a packet from a web server goes when it is addressed to the database at 10.0.11.20, and when it is addressed to a payment provider at 52.95.110.1. Explain the rule that decides between the routes.