Learning Objectives
- Understand CIDR notation and prefix lengths
- Convert between prefix length and subnet mask
- Identify the network and host portions of an address
What is CIDR Notation?
CIDR (Classless Inter-Domain Routing) notation is the way we write IP addresses with their prefix length:
192.168.1.0/24
The /24 tells us the first 24 bits are the network portion. The remaining 8 bits are the host portion.
Reading Prefix Lengths
The prefix length can be any number from 0 to 32 for IPv4:
| Prefix | Binary (Network/Portion) | Host Bits | Total Addresses |
|--------|------------------------|-----------|-----------------|
| /0 | 00000000 00000000 00000000 00000000 | 32 | 4,294,967,296 |
| /8 | 11111111 00000000 00000000 00000000 | 24 | 16,777,216 |
| /16 | 11111111 11111111 00000000 00000000 | 16 | 65,536 |
| /24 | 11111111 11111111 11111111 00000000 | 8 | 256 |
| /32 | 11111111 11111111 11111111 11111111 | 0 | 1 |
The Relationship to Subnet Mask
Every prefix length maps directly to a subnet mask:
- /24 = 255.255.255.0
- /25 = 255.255.255.128
- /26 = 255.255.255.192
- /27 = 255.255.255.224
- /28 = 255.255.255.240
- /29 = 255.255.255.248
- /30 = 255.255.255.252
- /31 = 255.255.255.254
- /32 = 255.255.255.255
Block Size Trick
Here's a pattern that makes subnetting faster: the block size (number of addresses) doubles as the prefix decreases.
Start at /32 = 1 address. Each time you subtract 1 from the prefix, the block size doubles:
| Prefix | Block Size | |--------|-----------| | /32 | 1 | | /31 | 2 | | /30 | 4 | | /29 | 8 | | /28 | 16 | | /27 | 32 | | /26 | 64 | | /25 | 128 | | /24 | 256 |
What subnet mask corresponds to /27?
How many addresses in a /28 network?
Which is larger — a /26 or a /30 network?
Key Takeaways
- CIDR notation uses a slash followed by the prefix length:
/xx - The prefix length tells you how many bits are the network portion
- Higher prefix = fewer host bits = smaller network
- Block size = 2^(32 - prefix length)
Next lesson: subnet masks in detail.