CIDR notation explained
Where CIDR came from, why the prefix length replaced network classes, and how to read the slash notation you meet in routing tables, firewall rules and cloud consoles.
Before CIDR: fixed classes
Until 1993, the first bits of an IPv4 address determined its size. A first octet starting with 0 meant class A and 16,777,216 addresses; a first octet starting with 10 meant class B and 65,536 addresses; starting with 110 meant class C and 256 addresses. The boundaries were hard, and there was no way to ask for anything in between.
| Class | Leading bits | First octet | Default mask | Addresses per network |
|---|---|---|---|---|
| A | 0 | 1–126 | 255.0.0.0 | 16,777,216 |
| B | 10 | 128–191 | 255.255.0.0 | 65,536 |
| C | 110 | 192–223 | 255.255.255.0 | 256 |
| D | 1110 | 224–239 | — | Multicast, no per-network sizing |
| E | 1111 | 240–255 | — | Reserved for experimental use |
Two problems compounded. First, waste: an organisation that needed 2,000 addresses had to take a class B and leave 63,000 unused. Second, routing table growth: every class A, B or C allocation became a separate entry in the global routing table, regardless of its size.
What CIDR changed
CIDR removed the fixed boundaries and replaced them with an explicit prefix length. A network of 1,000 addresses is now a /22 — 1,024 addresses, 4% waste instead of 98%. Two consequences followed, and both were the point of the change.
- Efficient use of space. An allocation can be sized to the requirement rather than to the next class up, so the address space lasts far longer.
- Route aggregation. Because addresses are no longer tied to class boundaries, an ISP holding 203.0.112.0/21 can advertise one route for all eight of its /24s. Aggregation is what kept the global routing table manageable through the 1990s and is still what makes the internet scale today.
192.168.1.0/24 Prefix length 24 Subnet mask 255.255.255.0 Wildcard mask 0.0.0.255 Inverse form 192.168.1.0 0.0.0.255 (Cisco ACL syntax)
Reading a prefix length without counting
Counting bits from scratch is unnecessary once you know the last-octet sequence. Prefixes longer than /24 only ever involve the fourth octet, and the mask values follow a fixed progression.
| Prefix | Last octet | Binary of last octet | Block size | Usable hosts |
|---|---|---|---|---|
| /24 | 0 | 00000000 | 256 | 254 |
| /25 | 128 | 10000000 | 128 | 126 |
| /26 | 192 | 11000000 | 64 | 62 |
| /27 | 224 | 11100000 | 32 | 30 |
| /28 | 240 | 11110000 | 16 | 14 |
| /29 | 248 | 11111000 | 8 | 6 |
| /30 | 252 | 11111100 | 4 | 2 |
| /31 | 254 | 11111110 | 2 | 2 (RFC 3021) |
| /32 | 255 | 11111111 | 1 | 1 |
The pattern is that each step adds one bit to the network portion, so the mask octet gains the next place value: 128, then 64, then 32, and so on. Reading /27 as 224 is a matter of recognising the sequence rather than doing arithmetic.
Longest prefix match in practice
The reason a prefix length has to be a contiguous run of bits is that routers resolve ambiguity by choosing the longest matching prefix. Consider a router with three routes:
10.0.0.0/8 via 192.0.2.1 10.1.0.0/16 via 192.0.2.2 10.1.2.0/24 via 192.0.2.3 Destination 10.1.2.55 matches all three. Longest match wins -> 10.1.2.0/24 via 192.0.2.3
This is what allows a specific exception to be carved out of a broad summary. The /8 carries most of the traffic; the /24 provides a more specific path for one subnet without needing to break the /8 into pieces. If masks could be non-contiguous, no single number would express specificity and the algorithm would fall apart.
Where you meet CIDR notation
- Routing tables. Every route is a prefix and a next hop. The default route is 0.0.0.0/0 and appears in every router's table.
- Firewall rules. Source and destination ranges are written as prefixes, and the choice of prefix directly determines how much traffic matches.
- Cloud networking. VPC and VNet address ranges are specified as CIDR blocks, and subnets are carved out of them — which means the prefix arithmetic determines whether your subnets fit at all.
- Vendor configuration. Interface addresses, OSPF network statements and route summarisation all use prefixes, and Cisco ACLs use the wildcard form of the same information.
- IPv6. The same notation applies with a range of /0 to /128, and a /64 — the standard subnet size — is so common that IPv6 subnetting is usually a question of how many /64s fit in an allocation rather than of masks.
Common mistakes
- Writing an address that is not the network address. 192.168.1.5/24 is a valid notation but the network is 192.168.1.0/24. Most systems accept and normalise the first form, but it is misleading in documentation.
- Assuming a larger number means a larger network. /28 is smaller than /24. The number counts network bits, so more bits means fewer host addresses.
- Confusing the prefix with the mask. A /24 is not “24 hosts” — it is 24 network bits and 254 usable hosts. The two numbers are easy to transpose when reading quickly.
- Using a non-contiguous mask. 255.255.0.255 looks plausible but is invalid and cannot be expressed as a prefix length, so no router will accept it.
Prefix range summary
| Range | Typical use | Notes |
|---|---|---|
| /0 | Default route | Matches every address; the last resort in a routing table |
| /1 – /7 | Historic class A aggregates | Rarely seen outside very large routing tables |
| /8 – /15 | ISP and cloud allocations | A /8 is 16,777,216 addresses |
| /12 | RFC 1918 private block | 172.16.0.0/12 is the private range |
| /16 – /22 | Enterprise and campus | A /16 contains 256 /24s for subdivision |
| /23 – /24 | Site and VLAN networks | A /24 is the standard LAN size, 254 hosts |
| /25 – /29 | Department segments | Divides a /24 into smaller broadcast domains |
| /30 | WAN links (classic) | Two usable hosts out of four addresses |
| /31 | WAN links (RFC 3021) | Two addresses, no waste |
| /32 | Host routes | Loopbacks and single-destination static routes |
For IPv6 the same table shifts by 96: a /64 is the standard LAN size, a /128 is a single host, and a /127 is the analogue of an IPv4 /31 for point-to-point links.
Related: CIDR calculator, CIDR reference table, subnetting guide, VLSM design guide.
Frequently asked questions
What does CIDR stand for and when was it introduced?
Classless Inter-Domain Routing. It was introduced in RFC 1518 and RFC 1519 in 1993 to replace the fixed class A, B and C boundaries, which had proved far too coarse for a growing internet. CIDR introduced the prefix length, allowing a network of any size from a /32 single host up to a /0 default route.
How is a prefix length different from a subnet mask?
They express exactly the same information in different notations. A prefix length counts the network bits, so /24 means 24 ones. A subnet mask writes those same bits out in dotted-decimal, so /24 is 255.255.255.0. Every prefix has exactly one valid mask, and every valid mask maps back to exactly one prefix.
Why was classful addressing a problem?
Class A gave 16 million addresses, class B gave 65,536 and class C gave 256, with nothing in between. An organisation needing 1,000 addresses had to take a class B allocation and waste 98% of it, and each of those allocations added a route to the global routing table. By the early 1990s the routing table was growing faster than routers could handle and the address space was being consumed far faster than necessary.
What does the slash notation look like in practice?
It appears after an address, as in 192.168.1.0/24 or 2001:db8::/32, and it can also stand alone when the prefix is all you care about, as in a routing table entry or a firewall rule. Cloud consoles usually show it as a separate field labelled 'prefix' or 'CIDR'.
What is the longest and shortest possible prefix?
For IPv4 the range is /0 to /32. A /0 matches every address and is used as the default route. A /32 matches exactly one address and is used for host routes and loopback interfaces. For IPv6 the range is /0 to /128, because an IPv6 address is 128 bits.
Can a subnet mask be non-contiguous?
No. A valid mask is a run of 1 bits followed by a run of 0 bits, with no interleaving. 255.255.0.255 is not a valid mask because there is a zero between ones. This restriction exists because the network/host division has to be expressible as a single prefix length, which is what makes longest-prefix-match routing possible.
What is longest prefix match?
When a router has several routes that could match a destination, it chooses the one with the longest prefix — the most specific match. A /32 host route beats a /24 subnet route, which beats a /16 summary, which beats the /0 default. This is what allows a small exception to be carved out of a large aggregate without disturbing the rest of it.