IPv4 addressing · Fundamentals · Module 4
VLSM: different sizes without overlap
Show topologyHide topology
Interfaces and addresses · Et = Ethernet. LAN C, LAN D and branch LAN 2 are planned and not cabled yet.
- 192.168.8.0/26 · LAN AR1 Et0/0 192.168.8.1H1 eth0 192.168.8.10
- 192.168.8.64/26 · LAN BR1 Et0/1 192.168.8.65R3 Et0/0 192.168.8.126
- 192.168.9.224/30R1 Et0/2 192.168.9.225R2 Et0/0 192.168.9.226
- 192.168.9.228/31R2 Et0/2 192.168.9.228R4 Et0/0 192.168.9.229
- 192.168.9.0/25 · branch LAN 1 · SW1R2 Et0/1 192.168.9.1no other device yet
- 192.168.9.192/27 · branch LAN 3 · SW2R4 Et0/1 192.168.9.193no other device yet
Device icons joined by plain cables, each cable labeled with its subnet. Down the middle, top to bottom: R3, a router; R1, the HQ router; R2, the branch router; R4, a branch router; and the switch SW2. R3 is cabled to R1 (192.168.8.64/26), R1 to R2 (192.168.9.224/30), R2 to R4 (192.168.9.228/31) and R4 to SW2 (192.168.9.192/27). At the upper left, the host H1, a laptop, is cabled down from its base to R1 (192.168.8.0/26). Left of R2, the switch SW1 is cabled across to it (192.168.9.0/25).
What VLSM is
Different sizes from one block
The branch block, 192.168.9.0/24, must hold a LAN of 100 hosts, a planned LAN of 50, a LAN of 20 and two links. Can one prefix length serve all five?
With one prefix for every need, the largest need decides it, and branch LAN 1, with 100 hosts, needs a /25. A /24 holds only 2 subnets of that size, so two needs get a block and the other three get none.
So each need takes its own prefix. LAN 3 needs 20 hosts and takes a /27, and a link of two routers takes a /30 or a /31.
VLSM, variable-length subnet masks, means subnets of different prefix lengths inside one block. Each need gets the smallest subnet that holds it, and all of them come from the same block.
Must a router accept such a plan? RFC 1812, the standard that sets the requirements for IPv4 routers, says that routers must support variable length network prefixes in their interface configurations.
The result is written down as an address plan: each need, the prefix and the block it gets, and the blocks left free. You type the routers’ addresses from the plan, and you check them against it.
With VLSM every branch need fits, and part of the block stays free (Figure 4.1).
Two bars, each the whole branch block, 192.168.9.0/24, each block named above it. The first bar, headed “One prefix for every need: /25”, is cut in two halves, LAN 1 and LAN 2. Under it: “No block left for LAN 3 or the two links”. The second bar, headed “VLSM: each need its own prefix” and highlighted, is cut into LAN 1 with /25, half the bar; LAN 2 with /26, a quarter; LAN 3 with /27, an eighth; and a last eighth, outlined only, tied by a short line to its label under the bar: “.224/27: the two links, then free”.
How it works
Largest first
Five needs of different sizes must share one block, with no address in two of them. In which order do you place them, and where does each one start?
Sort the needs largest first. Give each one the longest prefix that still holds its hosts, the smallest subnet that fits, and place it at the first free address that is a multiple of its block size.
Two subnets that share addresses overlap, and a plan must have no overlaps.
A subnet can start only at a multiple of its block size. An address typed anywhere else still falls in the aligned block around it, and that block may already belong to another need.
Why largest first? Every block is a power of two in size, so a larger block size is always a multiple of a smaller one. When the larger blocks come first, each one ends on a boundary where the next, smaller block can start, so the blocks neither overlap nor leave gaps.
Placed smallest first, the small blocks take the first addresses, and each larger block may have to skip ahead to its next boundary. The plan may still fit, but gaps can open between the blocks, and the larger block that skipped ahead cannot use them.
The branch plan gives the link from R1 to R2 a /30 and the link from R2 to R4 a /31, since each link joins two routers and needs only two host addresses. Step through Figure 4.2 to watch the plan built one need per step.
Step 1 of 7
The needs, largest first: LAN 1 100 hosts, LAN 2 50, LAN 3 20, and two links of 2 hosts each. All five share the whole block, 192.168.9.0/24.
Step 2 of 7
LAN 1 needs 100 hosts: a /25, which holds 126. Nothing is placed yet, so it starts at .0 and takes .0 to .127.
Step 3 of 7
LAN 2 needs 50: a /26, 62 hosts, block size 64. The first free address, .128, is a multiple of 64: LAN 2 gets .128/26.
Step 4 of 7
LAN 3 needs 20: a /27, 30 hosts, block size 32. The first free address, .192, is a multiple of 32: LAN 3 gets .192/27, up to .223.
Step 5 of 7
Next comes the link from R1 to R2. The plan gives it a /30: 4 addresses, so its block size is 4.
LAN 3 ends at .223. Where does the /30 for the link start?
- .224 (Correct): .224 is the first free address after LAN 3, and it is a multiple of 4. So the link gets .224/30, right after LAN 3, with no gap.
- .200: .200 is a multiple of 4, but it lies inside LAN 3, which runs from .192 to .223. The link would overlap LAN 3. A block goes on free addresses only.
- .222: .222 is not a multiple of 4. A /30 typed there still falls in the block that starts two addresses lower, inside LAN 3.
- .232: .232 is free and a multiple of 4, but it skips the free addresses from .224 on and leaves them as a gap.
Step 6 of 7
The first free address, .224, is a multiple of 4: the link from R1 to R2 gets .224/30. The link from R2 to R4 takes its /31 at the next free address, .228.
Step 7 of 7
Every need fits, each on its own boundary, with no gap between the blocks. Left free for later: .230/31, .232/29 and .240/28.
At the top, a list shows the five needs, largest first, as “LAN 1: 100 hosts”, “LAN 2: 50 hosts”, “LAN 3: 20 hosts”, “Link R1 to R2: 2 hosts” and “Link R2 to R4: 2 hosts”. As each need is placed, its block appears at the right end of its row. The blocks are .0/25, .128/26, .192/27, .224/30 and .228/31. Under the list, the block 192.168.9.0/24 as a bar with a dashed outline; each placed block is drawn solid over it, so free space stays dashed. The list row being worked on is highlighted: its need on step 1 and on step 5, its new block from step 2 to step 4 and on step 6. From step 2 to step 4, LAN 1 fills its first half, LAN 2 the next quarter and LAN 3 the next eighth, each named above its block. From step 6, a row under the bar, titled “Zoom from .224”, opens the next part of the block, drawn wider: the link from R1 to R2 and then the link from R2 to R4, each named under its block, then two empty dashed cells. At step 7, the empty cells are tagged “.230 free”, under its cell, and “.232/29 free”; the empty, dashed sixteenth at the bar’s right end is tagged .240 above it; and at the foot is the line “Free: .230/31 · .232/29 · .240/28”.
Predict the next step, then go on.
Key idea
Largest first, each need takes the longest prefix that still holds its hosts and starts at the first free multiple of its block size.
Plan it yourself
Another block, 192.168.10.0/24, must hold LANs of 60, 30 and 10 hosts, and one link. Where does each one go?
LAN X, the largest LAN, is already placed. You place LAN Y and then LAN Z, each by its prefix and the last octet of its start address.
Set the prefix, type the start, then submit.
Requirements
- LAN X: 60 hosts192.168.10.0/26
- LAN Y: 30 hostsnot placed yet
- LAN Z: 10 hostsnot placed yet
Place LAN Y: 30 hosts
A /25 starts at a multiple of 128: .0, .128.
Type the last octet of the start address.
Place LAN Z: 10 hosts
A /25 starts at a multiple of 128: .0, .128.
Type the last octet of the start address.
| Requirement | Hosts | Subnet |
|---|---|---|
| LAN X | 60 | 192.168.10.0/26 |
| LAN Y | 30 | ? |
| LAN Z | 10 | ? |
Where does LAN Y go?
Answer
192.168.10.64/27
30 hosts need a /27, which holds 30 hosts in a block of 32. LAN X takes the first 64 addresses, so the first free address is .64, a multiple of 32, and LAN Y gets .64/27.
Where does LAN Z go?
Answer
192.168.10.96/28
10 hosts need a /28, which holds 14 hosts in a block of 16. LAN Y ends just before .96, which is a multiple of 16, so LAN Z gets .96/28.
The plan gives the link, which joins two routers, a /31.
Place the three LANs first, then find the link’s start.