Subnet Smith — DevOps

Pick the right CIDR prefix for the hosts and IPv4 subnets you need: 18 levels of subnet masks, network and host bits and IP ranges.

What you learn in this game

Sukamaju Net shares one internet line across the whole village, and every house needs one IPv4 address: 32 bits, written as four numbers like 192.168.1.7. A block /p fixes the first p bits and lets the other 32 − p bits vary, so it holds 2^(32 − p) addresses. On the volleyball court, that block is a fenced plot of land. Its first address is the gate (the network address) and its last the alarm drum (the broadcast, to call every house at once), so the houses that fit are 2^(32 − p) − 2. The longer the prefix, the smaller the plot. What you want: the smallest plot that still holds every house. The village uses the RFC 1918 private blocks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), which never go out to the internet. The block 100.64.0.0/10 belongs to the internet provider (CGNAT, RFC 6598): the address on Ms. Dyah’s router on the tower side comes from there, so it is not used inside the village.

A plot of houses needs a gate (the network address) and a broadcast, so a /30 leaves only 2 of its 4 addresses. A point-to-point link is another matter: it has just two ends, and nobody to call all at once. RFC 3021 allows a /31 on such a link: two addresses, no gate and no alarm drum, both of them used. Python’s ipaddress also gives both addresses of a /31 as hosts. A /31 is only for a link. A plot with houses still needs its gate and its alarm drum, so the smallest is a /30. A /32 is one address for one machine, not a plot for a group of houses.

Sometimes the ask is not a number of houses but a number of equal plots: one for each neighbourhood. Every prefix bit you add splits every plot in two, so the number of plots is 2^(new_prefix − base_prefix). Split only as much as needed: every extra split halves every neighbourhood’s plot.

2^n − 2 is the textbook count: one address for the network, one for the broadcast. In the cloud, providers keep more. AWS reserves five addresses in every VPC subnet (the first four and the last), Azure five as well, Google Cloud four. A /27 on AWS holds only 27 machines, not 30. IPv6 has no broadcast at all, and an IPv6 LAN is always a /64: there is nothing to save. Sukamaju Net runs on an ordinary village router, so the 2^n − 2 count holds here.

From this level on you also place the plot on the map. A block /p may only start at a multiple of its own size: at its network address, every host bit is zero. A plot that starts anywhere else has a fence that cuts across a neighbour’s line, and a router cannot write it down as one block. Place a plot on the first free spot that lines up, so the ground left stays whole for the next ask.

VLSM (variable length subnet mask): one block shared out into plots of different sizes, each as tight as its ask. The order matters. Place the biggest first, each plot on the first free spot that lines up. A big plot always starts at a multiple of its size: if a small plot already sits at the start of the ground, the big one must jump to its next multiple and leave a fallow gap behind it. Biggest first, every plot ends exactly where the next one may start, so there is no gap.

What the levels ask

  1. Tap − and + for the prefix length: every extra bit splits the plot in two. Then tap Stake it.
  2. A plot too small makes laptops spill over the fence; one too big wastes ground.
  3. Few devices, small plot. The ground left is kept for whoever comes next.
  4. This link has no other houses: only the radio on the tower and the radio at the hall.
  5. A new plot lands on the first free ground that suits its size.
  6. Every extra prefix bit splits every plot in two. Split as little as you can, so each plot stays big.
  7. More plots means a longer prefix and fewer addresses per plot.
  8. A plot may be bigger than a /24: a shorter prefix, more addresses.
  9. The first power of two that is not less than the number of neighbourhoods.
  10. A very big block takes a very short prefix.
  11. Remember the gate and the alarm drum: 32 addresses are not 32 houses.
  12. When the ask is not a power of two, go up to the next power of two.

And more, 18 levels in all.