Sikau

AWS · Day 9 · about 40 min

Subnets and route tables

Carve a VPC into subnets and decide where each packet goes.

Public is a routing fact

Your VPC is one big private address range, such as 10.0.0.0/16. You cut it into subnets, each living in one Availability Zone: 10.0.1.0/24 for web servers, 10.0.2.0/24 for databases. Here is the surprise: no subnet is public or private by name. What makes one public is its route table.

A route table is a short list of destination -> target rules. A subnet whose table sends 0.0.0.0/0 (everything else) to an internet gateway is called public. If there is no such route, packets for the internet have nowhere to go, and the subnet is private.

Reading a CIDR block

10.0.1.0/24 means the first 24 bits are fixed and the last 8 are free. That gives 2^8 = 256 addresses, 10.0.1.0 to 10.0.1.255. A smaller number after the slash is a bigger block: /16 holds 65,536 addresses and /32 is exactly one.

  • /16 is a whole VPC, a good starting size.
  • /24 is a typical subnet.
  • /32 is a single address, handy for allow-listing one machine.
  • 0.0.0.0/0 matches every address on the internet.

AWS reserves five addresses in every subnet (the first four and the last), so a /24 gives you 251 usable ones, not 256.

The rest of this lesson

  • Most specific route winsexplain
  • Which route?predict
  • Name the componentmatch
  • A packet leavesorder
  • Build the routerwrite code
  • Badge quizquiz
  • What you learnedrecap