What is CIDR notation?

CIDR (Classless Inter-Domain Routing) is the modern way to describe an IP block using a prefix length, like 192.0.2.0/24. It replaced the old class A, B, and C system with something far more flexible.

Last reviewed:

Looking for the complete table instead? Every prefix from /0 to /32, with mask, wildcard and host count, is on the CIDR reference.

Before CIDR: the classful system

The original internet split addresses into fixed classes. Class A was a /8, class B a /16, class C a /24. The problem was rigidity: an organisation that needed 2,000 addresses had to take a whole class B of 65,536, wasting most of it, because a class C of 256 was too small.

CIDR, introduced in 1993, threw out the fixed boundaries. Now any prefix length is allowed, so that same organisation can take a /21 (2,048 addresses) that fits its need almost exactly.

How CIDR notation works

CIDR notation is an address followed by a slash and a number: 192.0.2.0/24. The number is the prefix length, the count of leading bits that identify the network. Everything after those bits is available for hosts.

The prefix maps directly to a subnet mask. /24 is 255.255.255.0, /16 is 255.255.0.0, /30 is 255.255.255.252. It also maps to a size: the host portion has 32 minus the prefix bits, so a /24 has 8 host bits and therefore 256 addresses. The CIDR calculator on this site expands any block into its exact range.

A worked example, in binary

CIDR is easiest to believe once you have watched the bits. Take 192.0.2.0/24 and write the address out as 32 bits, four groups of eight.

The /24 says the first 24 bits are the network. Everything to the left of that line is fixed for every host in the block; everything to the right is free. Set the free bits all to 0 and you have the network address, 192.0.2.0. Set them all to 1 and you have the broadcast address, 192.0.2.255. The addresses in between, 192.0.2.1 to 192.0.2.254, are the hosts.

Move the line one bit to the right and the block halves. A /25 fixes 25 bits, leaving 7 free, which is 128 addresses and 126 hosts. That is the whole idea: the prefix length is a position, and moving it is the only thing that changes the size.

192.0.2.0/24 written out bit by bit
ValueBinaryDecimal
Address11000000.00000000.00000010.00000000192.0.2.0
Mask (/24)11111111.11111111.11111111.00000000255.255.255.0
Wildcard00000000.00000000.00000000.111111110.0.0.255
Network11000000.00000000.00000010.00000000192.0.2.0
Broadcast11000000.00000000.00000010.11111111192.0.2.255

The mask and the wildcard are exact bitwise complements of one another, which is worth checking whenever a value looks wrong.

What CIDR replaced: the classful boundaries

Before CIDR, the first bits of the address decided the size of the block, and there were only three usable sizes. An organisation that needed 500 addresses had to take a class B of 65,536, because the next size down held 256. That mismatch is what exhausted the address space, not the number of hosts on the internet.

CIDR removed the coupling between the address and the block size. The prefix is carried alongside the address, so a 500-host organisation gets a /23 with 510 usable addresses and nothing is wasted.

The classful sizes compared with their CIDR equivalents
ClassLeading bitsFirst octetFixed sizeCIDR equivalent
A01 to 12616,777,216 addresses/8
B10128 to 19165,536 addresses/16
C110192 to 223256 addresses/24
D1110224 to 239Multicast, not allocated224.0.0.0/4
E1111240 to 255Reserved240.0.0.0/4

127 is missing from class A on purpose: 127.0.0.0/8 is loopback under RFC 1122. Classes A, B and C stopped being a real thing in 1993, but the vocabulary outlived them, which is why people still say class C when they mean /24.

Route aggregation, and why the internet needs it

The second half of CIDR is aggregation, and it is the half that actually saved the routing table. A provider holding 198.51.100.0/24, 198.51.101.0/24, 198.51.102.0/24 and 198.51.103.0/24 does not advertise four routes to its BGP neighbours. It advertises 198.51.100.0/22, one route covering all four, because the four blocks are contiguous and start on a /22 boundary.

The boundary condition is what makes it work and what makes it fail. Those four /24s aggregate because 100 in binary is 01100100 and the last two bits are the only ones that vary. Four /24s starting at 198.51.101.0 would not aggregate into a /22, because 101 is not a multiple of 4. Address plans are laid out on power-of-two boundaries precisely so aggregation stays possible later.

Routers resolve overlapping routes by longest prefix match: the most specific route wins. A /22 aggregate and a more specific /24 can both exist, and traffic for that /24 follows the /24. This is what lets a customer move one block to a different provider without renumbering, and it is also why the global table keeps growing despite aggregation.

Four contiguous /24 blocks aggregating into one /22 route
BlockThird octet in binaryCovered by
198.51.100.0/2401100100198.51.100.0/22
198.51.101.0/2401100101198.51.100.0/22
198.51.102.0/2401100110198.51.100.0/22
198.51.103.0/2401100111198.51.100.0/22

The first six bits are identical across all four; only the last two vary. That is exactly what a /22 fixes, so the four collapse into one advertisement. The supernet calculator does this for any set of blocks.

CIDR and route aggregation

CIDR's other superpower is summarisation. Several adjacent blocks can be advertised as one shorter prefix. Four contiguous /24s can become a single /22, which keeps the global routing table smaller. That is what supernetting does, and you can try it with the supernet calculator.

This is why CIDR is called classless and inter-domain: it lets providers hand out right-sized blocks and aggregate routes across the whole internet, independent of the old class boundaries.

Frequently asked questions

What does /24 mean in CIDR?

The /24 means the first 24 bits are the network prefix. That leaves 8 bits for hosts, so the block has 256 addresses (254 usable) and the mask 255.255.255.0.

What is a CIDR block?

A CIDR block is a range of IP addresses described by a base address and a prefix, such as 10.0.0.0/8. It represents every address that shares those leading prefix bits.

How do I convert CIDR to an IP range?

The base address with all host bits set to 0 is the first address, and with all host bits set to 1 is the last. The CIDR calculator does this instantly for any block.

Is CIDR the same as a subnet mask?

They describe the same boundary. /24 in CIDR is 255.255.255.0 as a subnet mask. CIDR is just a shorter way to write the prefix length.

Sources

Everything technical on this page is checkable against the documents below. Where a document and common practice disagree, the guide says so rather than picking one quietly.

Spotted something wrong? Tell us and it gets corrected. How the data is maintained is described on the about page.