lesson 3.3 · chapter 3 of 5: addresses · 30 min
Subnetting with VLSM
objective
Cut one block of addresses into subnets of different sizes with VLSM: biggest first, the smallest block that fits, no overlaps, and write down each subnet’s network, hosts and broadcast.
Sharing out a block of addresses
Sharing a pizza fairly
Five friends share a big pizza. One is starving, one is quite hungry, and three just want a nibble. If you cut it into five equal slices, the starving one goes hungry and the nibblers leave crusts. If you cut big slices for the hungry ones and small slivers for the rest, everyone gets what they need and there might even be some left over.
in one sentence Give each person the size of slice they need, not the same slice for everyone.
Subnets
A school or company is usually given one block of addresses, like 192.168.10.0/24 (256 addresses: from
lesson 3.2). Cutting that block into smaller networks is called subnetting, and each small network is a
subnet (sub means under or part of, like a submarine goes under the sea).
Why cut it up?
- Groups: students, teachers and cameras each get their own subnet, so each can have its own rules.
- Fewer announcements: each subnet is its own broadcast domain (lesson 2.2), so broadcasts stay smaller.
- No waste: each group gets the size it needs.
in one sentence Subnetting cuts one block of addresses into smaller networks called subnets.
VLSM: a different size for each
The simple way is to cut equal pieces, but groups aren’t equal: 100 students and 2 addresses for a cable between two routers. Equal pieces big enough for the biggest group would waste nearly all of the small ones.
VLSM stands for Variable Length Subnet Masks. Variable means can change, and the length is the prefix from lesson 3.2. So: each subnet gets its own prefix, just big enough for its group. That’s the pizza cut to fit.
in one sentence VLSM gives each subnet its own prefix, so each group gets the size it needs.
Sizes come in doubles
Subnets can’t be any size: they come in powers of two, numbers you get by doubling, starting from 1: 2, 4, 8, 16, 32, 64, 128, 256. That’s because each host bit doubles the addresses (lesson 3.2). And remember, every subnet loses two addresses: the network address and the broadcast.
| Hosts needed (up to) | + 2 | Block size | Prefix |
|---|---|---|---|
| 2 | 4 | 4 | /30 |
| 6 | 8 | 8 | /29 |
| 14 | 16 | 16 | /28 |
| 30 | 32 | 32 | /27 |
| 62 | 64 | 64 | /26 |
| 126 | 128 | 128 | /25 |
| 254 | 256 | 256 | /24 |
in one sentence A subnet’s size is a power of two, and two of its addresses are always taken.
The recipe
- List the groups, biggest first.
- For each group, add 2 (for the network address and the broadcast).
- Find the smallest power of two that’s at least that number. That’s the block size. Which power it is, is the number of host bits: 64 = 2⁶, so 6 host bits.
- The prefix is 32 minus the host bits: 32 − 6 = /26.
- Place it at the next free address. A block has to start at a multiple of its own size (a block of 64 starts at 0, 64, 128 or 192). Going biggest first means it always does, with no gaps.
- Write down the network (the first address), the hosts (everything between) and the broadcast (the network plus the block size, minus 1).
in one sentence Biggest first, add 2, round up to a power of two, place it at the next free address.
A school’s network
A school has the block 192.168.10.0/24: 256 addresses. It needs five subnets:
| Group | Hosts |
|---|---|
| Students | 100 |
| Teachers | 50 |
| Office | 20 |
| Cameras | 10 |
| Link between two routers | 2 |
With equal pieces, every subnet would have to fit 100 students: a /25 each, 128 addresses. Five of those is 640 addresses, and the school only has 256. It doesn’t fit! With VLSM, it does, with room to spare. Watch.
in one sentence Equal slices don’t fit this school’s 256 addresses; slices cut to size do.
Carve it up, step by step
The bar is the whole block, .0 on the left to .255 on the right. Each step carves out one subnet, and the
table fills in. Press Play, or step with → and say each answer out loud before you look.
| subnet | hosts | block | network | usable hosts | broadcast |
|---|
Let’s check one by hand, the Office:
- 20 hosts + 2 = 22.
- The smallest power of two that’s at least 22 is 32 = 2⁵. So 5 host bits.
- Prefix: 32 − 5 = /27.
- Students used
.0to.127, Teachers.128to.191. The next free address is.192, and 192 is a multiple of 32. ✓ - Network
192.168.10.192/27, hosts.193to.222, broadcast.192 + 32 − 1=.223.
Now check the Cameras the same way, then compare with the table.
in one sentence Each subnet takes the smallest power-of-two block that fits its hosts plus two, placed biggest first.
Your turn: a gaming club
A gaming club has the block 172.16.0.0/24. Plan its subnets with VLSM:
| Group | Hosts |
|---|---|
| Library | 25 |
| Gaming lab | 60 |
| Printers | 5 |
| Staff | 12 |
| Router link A | 2 |
| Router link B | 2 |
For each one, write the prefix, network, usable hosts and broadcast. How many addresses are left over?
hint
Sort them first: Gaming lab 60, Library 25, Staff 12, Printers 5, then the two links.
hint
Gaming lab: 60 + 2 = 62, so a block of 64, a /26, starting at 172.16.0.0. Library: 25 + 2 = 27, so a block of 32, a /27, starting at .64.
hint
Each router link is a /30, a block of 4.
show the solution
Here it is, step by step:
| subnet | hosts | block | network | usable hosts | broadcast |
|---|
| Group | Prefix | Network | Usable hosts | Broadcast |
|---|---|---|---|---|
| Gaming lab | /26 | 172.16.0.0 | .1 – .62 | 172.16.0.63 |
| Library | /27 | 172.16.0.64 | .65 – .94 | 172.16.0.95 |
| Staff | /28 | 172.16.0.96 | .97 – .110 | 172.16.0.111 |
| Printers | /29 | 172.16.0.112 | .113 – .118 | 172.16.0.119 |
| Link A | /30 | 172.16.0.120 | .121 – .122 | 172.16.0.123 |
| Link B | /30 | 172.16.0.124 | .125 – .126 | 172.16.0.127 |
128 addresses are left over: 172.16.0.128 to 172.16.0.255, a whole /25, ready for whatever the club needs next.
5 check: test yourself
Pick an answer for each question. You'll see straight away whether it's right, and why. Questions marked what happens next? are about the animations.
A subnet needs 20 hosts. What’s the smallest prefix that fits?
20 + 2 = 22. The smallest power of two that’s at least 22 is 32, which is 5 host bits: 32 − 5 = /27, with 30 hosts. A /28 only has 14.
Why place the biggest subnets first?
Big blocks have the strictest starting places. Put them in first and the small ones fit neatly after them.
what happens next?In the animation, Students (/25) has just been placed at
192.168.10.0, using.0to.127. What happens next?Teachers is the next biggest, and the next free address is
.128, which is a multiple of 64. ✓A cable between two routers needs just two addresses. Which prefix?
/30 has 4 addresses: the network, two hosts, and the broadcast. Exactly enough.