TwiceToldby Develoker
ConceptsSystem designLabsCheat sheetsAbout

Develoker makes free tools for learning to build software. TwiceTold explains each idea twice, as an everyday analogy and the real thing; CloudArch lets you design cloud systems and put load on them.

About ยท Labs ยท Cheat sheets ยท Learning paths

โ† Back to Amazon VPC: subnets, route tables and security groups

๐Ÿ˜๏ธ Amazon VPC: subnets, route tables and security groups: cheat sheet

๐ŸŽจ The analogyA gated housing estate with its own house numbers, some streets with a road to the gate and some without.
๐ŸŽ“ The regular explanationA VPC is your own isolated network in an AWS Region. You split its IP range into subnets in each Availability Zone, route tables decide which subnets reach the internet, and security groups and network ACLs filter the traffic.
A VPC and its subnetsStep 4 of 4
๐Ÿ›ฃ๏ธ Street 1, plot A๐Ÿ›ฃ๏ธ Street 2, plot B๐Ÿง‘โ€๐Ÿ’ผYou๐Ÿ˜๏ธYour estate65,536 addressesโœ• โœ•๐Ÿ’ซHouse 1.10plot A๐Ÿ House 2.10still up
  1. You fence off your own estate and claim a block of house numbers, every number starting with 10.0.
  2. You lay out Street 1 on plot A, using the numbers starting 10.0.1, and build a house on it.
  3. You lay out Street 2 on a second plot, B, with its own power and water, and build a matching house.
  4. Plot A loses power and House 1.10 goes dark. House 2.10 on plot B keeps its lights on.
Public and private subnetsStep 5 of 5
๐Ÿ›ฃ๏ธ Front street๐ŸŒณ Quiet streetFront signpostlockey 10.0.0.0/16 โ†’ local: local0igwkey 0.0.0.0/0 โ†’ igw-1: igw12Quiet signpost ยท no routelockey 10.0.0.0/16 โ†’ local: local012๐ŸงVisitor๐ŸšชMain gateno public IP to map๐Ÿ Front housepublic IP๐ŸกQuiet houseno way in
  1. Both signposts start with one line, "inside the estate, just walk there", so the two houses can visit each other.
  2. The front street's signpost gets a second line, "anywhere else, go to the main gate", and the front house gets an outside address.
  3. A visitor from the city writes to the front house's outside address. The main gate lets them in and the reply goes back the same way.
  4. The visitor tries to reach the quiet house too. It has no outside address and no road to the gate, so there's simply no way in.
  5. The quiet house wants to order spare parts from the city. Its signpost only knows the estate, so the letter goes nowhere.
A NAT gateway for outbound-only accessStep 5 of 5
๐ŸŒณ Quiet street, plot A๐Ÿ›ฃ๏ธ Front street, plot A๐ŸกQuiet house0.0.0.0/0 โ†’ nat-1โœ• โœ•๐Ÿ’ซPost roomone per AZ๐ŸšชMain gate๐ŸญSupplier๐Ÿ•ต๏ธStranger
  1. The quiet street's signpost now says "anywhere else, go to the post room", so the quiet house hands its letter there.
  2. The post room sends the letter out through the main gate with its own return address, not the house's.
  3. The supplier replies to the post room, which remembers who asked and passes the reply on to the quiet house.
  4. A stranger writes to the post room hoping to reach a quiet house. Nobody in the estate asked, so the post room has nowhere to send it.
  5. Plot A loses power and its post room shuts. The quiet house can't send anything out, which is why busy estates have a post room on every plot.
Security groupsStep 4 of 4
๐Ÿšช Workshop front door๐Ÿ›Ž๏ธLodge๐ŸงNeighbourtimed out๐Ÿ’‚Doormanin: 8080 from sg-lb๐Ÿ Workshop๐Ÿ”Strongroomin: 5432 from sg-app
  1. The workshop's doorman has one line on the guest list, "the lodge may knock on the front door". The lodge knocks and walks in.
  2. The workshop answers. The doorman remembers the lodge came in, so the answer goes straight out without a second check.
  3. A neighbour who isn't on the list knocks. There's no "keep out" line to read; they just aren't on the list, so the doorman quietly ignores them.
  4. The strongroom's doorman lists "anyone whose doorman is the workshop's doorman". The workshop asks for records and gets them.
Network ACLsStep 5 of 5
๐Ÿ›ฃ๏ธ Front streetBarrier card: way in ยท * deny all100key 100 DENY all from 203.0.113.0/24: 1000200key 200 ALLOW TCP 443 from 0.0.0.0/0: 20012matchBarrier card: way out ยท * deny all100key 100 ALLOW TCP 1024-65535 to 0.0.0.0/0: 100012match๐ŸงVisitor๐Ÿ•ต๏ธBanned visitortimed out๐Ÿ Front house
  1. The barrier keeper's card for the way in has two numbered lines, "100, keep out the banned visitor" and "200, let in anyone for the front house". Anything else is turned back.
  2. A visitor arrives. The keeper reads line 100 (not them), then line 200 (yes), and lifts the barrier.
  3. The front house answers, but the keeper has no memory. The way-out card has no line for the reply, so it's stuck at the barrier.
  4. You add a line to the way-out card, "100, replies may go out". Now the answer reaches the visitor.
  5. The banned visitor tries. Line 100 fits first, so the keeper keeps them out, even though line 200 would have let them in.
A typical layoutStep 4 of 4
๐Ÿ›ฃ๏ธ Front streets๐ŸŒณ Quiet streets๐ŸŒฒ Quietest streets๐Ÿ‘ฅVisitors๐Ÿ›Ž๏ธLodgeโœ• โœ•๐Ÿ’ซWorkshop A๐Ÿ Workshop Bโœ• โœ•๐Ÿ’ซStrongroom A๐Ÿ”Spare strongroom Bnow primary
  1. A visitor arrives at the lodge on the front street. The lodge walks them to Workshop A on a quiet street.
  2. The workshop fetches what it needs from the strongroom and sends the answer back through the lodge.
  3. A visitor tries to walk straight to the strongroom. No road leads there from the city, so they can't.
  4. Plot A loses power. The spare strongroom on plot B takes over, and the lodge sends every visitor to Workshop B.

๐Ÿงฉ Key questions

A house sits on a street whose signpost has no line pointing to the main gate. What can visitors from the city do?
Nothing: no road leads there from the city, and the house can't get out either. What makes a street a front street is its signpost line to the main gate. Without it, the doorman never even sees city visitors.
The quiet houses need to order parts from a supplier in the city, but strangers must never reach them. What do you add?
A post room on a front street, with the quiet street's signpost pointing to it. The post room sends letters out under its own address and only passes on replies to letters a house sent first.
The front house's doorman lets a visitor in. On the way out, does the answer need its own line on the doorman's list?
No: the doorman remembers who came in and lets the answer out. That's the doorman. The barrier keeper at the end of the street is the one with no memory.
You must keep one troublesome address out of a whole street, even though the doormen let everyone in for the front house. Who can do that?
The barrier keeper, with a low-numbered keep-out line on the card. Doormen only have let-in lines. The barrier keeper's card can say keep out, and the lowest line that fits wins.
You build only one post room, on plot A. Plot A loses power. What happens to quiet houses on plot B?
They can't send letters out until plot A's power is back. A post room lives on one plot, so busy estates build one on every plot.