CIDR writes a network as an address and a prefix length, such as 10.1.0.0/24, and allows blocks of any power-of-two size to be allocated and combined. Allocate subnets of different sizes largest first, each starting on a multiple of its own size, and combine consecutive blocks into a single route only when together they fill an aligned block exactly. Four consecutive /24 blocks starting at 10.1.0.0 combine into 10.1.0.0/22 with 1,024 addresses, but the four blocks from 10.1.1.0 to 10.1.4.0 cannot.
Part of Networking
Slash notation, the alignment rule for subnet blocks, variable-length allocation for a settlement, and the arithmetic of combining routes.
A Block Is Its First Address, A Prefix Length And An Alignment Rule
A CIDR block is written address/prefix, such as 10.1.0.0/24. The prefix length p says that the first p bits are the network and the remaining h = 32 - p bits are host bits, as in Subnet Masks. The block holds 2^h addresses. One rule makes everything else work: a block of 2^h addresses must start at an address whose host bits are all zero, which means a multiple of 2^h. A /26 holds 64 addresses and starts at a multiple of 64 (.0, .64, .128, .192); a /22 holds 1,024 and, in the third octet, starts at a multiple of 4.
The older scheme fixed block sizes by the first octet; Network Addressing already uses prefix lengths and gives a /28 subnet of a /24 as 16 subnets of 14 hosts. This article adds variable-length allocation and aggregation. Every figure below was checked with a program as well as by hand.
What You Need
- The subnet table from Subnet Masks
- A requirements list — how many machines each part of the settlement needs, plus one address for the router on each subnet
- A block to carve up — the settlement’s /24 from IP Addressing
Method: Allocate Variable-Length Subnets
Step 1: Size each requirement Add 2 for the network and broadcast addresses, add 1 for the router interface, round up to the next power of two, and read off the prefix.
Step 2: Sort largest first Larger blocks need larger alignment, so placing them first leaves the small blocks to fill the gaps.
Step 3: Place each at the next aligned address Start at the beginning of the block and place each subnet at the first address after the last one that is a multiple of its own size.
Step 4: Record the free space The addresses left are your growth. Write them down with the rest of the plan.
Worked Example: A Settlement’s /24 Divided Five Ways
Block: 10.1.0.0/24 (256 addresses). Requirements: 100 home machines, 60 workshop machines, 20 servers, and three router-to-router links of 2 addresses each.
| Need | Hosts + router | Smallest size | Prefix | Network | Usable | Broadcast |
|---|---|---|---|---|---|---|
| Homes | 100 + 1 = 101 | 128 | /25 | 10.1.0.0 | .1 to .126 | 10.1.0.127 |
| Workshops | 60 + 1 = 61 | 64 | /26 | 10.1.0.128 | .129 to .190 | 10.1.0.191 |
| Servers | 20 + 1 = 21 | 32 | /27 | 10.1.0.192 | .193 to .222 | 10.1.0.223 |
| Link 1 | 2 | 4 | /30 | 10.1.0.224 | .225 to .226 | 10.1.0.227 |
| Link 2 | 2 | 4 | /30 | 10.1.0.228 | .229 to .230 | 10.1.0.231 |
| Link 3 | 2 | 4 | /30 | 10.1.0.232 | .233 to .234 | 10.1.0.235 |
The usable counts are 126, 62, 30, 2, 2 and 2, each at least the requirement (101, 61, 21, 2, 2, 2 including the router). Space used: 128 + 64 + 32 + 4 + 4 + 4 = 236 addresses. Free: 256 - 236 = 20 addresses, 10.1.0.236 to 10.1.0.255, which can still hold a /28 at .240 (16 addresses) with 4 left over.
Why largest first? Put a link at 10.1.0.0/30 first, and the next /25 must start at the next multiple of 128, which is 10.1.0.128. Addresses 10.1.0.4 to 10.1.0.127 are then unusable by the /25 and would be stranded unless smaller subnets fill them. Alignment, not total size, is what fragments a block.
Combining Routes: The Block Must Fill Exactly
A router that must send four settlements’ traffic the same way would otherwise hold four routes (Routing Tables). Blocks can be combined into one only if they are contiguous, their number is a power of two, and the first starts on a multiple of the combined size.
Works. 10.1.0.0/24, 10.1.1.0/24, 10.1.2.0/24, 10.1.3.0/24. Four blocks of 256 = 1,024 = 2^10 addresses, so the combined prefix is 32 - 10 = 22. In the third octet the block size is 4 and the first third-octet value is 0, a multiple of 4. The route is 10.1.0.0/22, mask 255.255.252.0 (third octet 11111100 = 252), covering 10.1.0.0 to 10.1.3.255.
Does not work. 10.1.1.0/24 to 10.1.4.0/24. These are also four contiguous blocks, but the first third-octet value is 1, not a multiple of 4. The /22 containing 10.1.1.0 is 10.1.0.0/22, which would also claim 10.1.0.0/24 (not yours), and 10.1.4.0 falls in the next /22. The best that can be done is three routes: 10.1.1.0/24, 10.1.2.0/23 (two blocks starting at the even value 2) and 10.1.4.0/24.
The practical consequence is a numbering rule: give each region of a multi-settlement network an aligned block, for example a /21 per region (2^(24-21) = 8 settlement /24s), and number the settlements inside it. The routers outside the region then need one route for the whole region.
Edge Cases
- /32 is one address, used to name a single machine in a route
- /31 is a two-address block used on point-to-point links, where the usual 2^h - 2 rule would leave none; this is from general knowledge, not from the other articles, and not every old router supports it, so use /30 unless you have tested /31
- /0 is every address, the default route (Routing Basics)
Common Mistakes
- Sizing a subnet to exactly the number of machines — forgetting the 2 reserved addresses and the router interface leaves no room
- Placing small subnets first — alignment strands address space
- Aggregating blocks that are not aligned — the combined route then claims addresses that belong to someone else, and traffic for them goes the wrong way
What’s Next
- Learn next: Private Ranges — the blocks these plans are carved from
- Combine with: Routing Tables — the longest-match rule that makes combined and specific routes coexist