Skip to content

Guide · 6 min read

What is a CIDR block?

The number after the slash in a CIDR block is not a size, a count, or an octet. It is a position — and once you see it that way, every other piece of subnet arithmetic falls out of it.

The slash is a boundary, not a quantity

Write 10.0.0.0/16 and you have said two things. The address is 10.0.0.0, and the first 16 bits of it are fixed. Every address that shares those first 16 bits belongs to the block; every address that does not, does not.

An IPv4 address is 32 bits. Fix 16 of them and 16 remain free, so the block holds 216 = 65,536 addresses. That is the whole calculation. The prefix length tells you where the boundary sits, and the boundary tells you the size.

10.0.0.0/16

00001010.00000000 . 00000000.00000000
└──── fixed ────┘   └──── free ─────┘
     16 bits             16 bits
                    = 65,536 addresses

This is why the numbers go the "wrong" way. A larger prefix is a smaller block: /24 fixes more bits than /16, leaving fewer free, so it holds fewer addresses. A /32 fixes everything and describes exactly one address.

CIDR stands for Classless Inter-Domain Routing

The classless part is historical, and it explains why the notation exists at all. Before 1993, the boundary was not something you chose — it was implied by the first bits of the address itself:

ClassRangeImplied boundaryHosts
A0.0.0.0 – 127.255.255.255/816,777,214
B128.0.0.0 – 191.255.255.255/1665,534
C192.0.0.0 – 223.255.255.255/24254

Three sizes, and nothing in between. An organisation with 400 hosts had to take a class B and waste 65,000 addresses, or take two class Cs and run two routing entries. Both choices were bad, and at internet scale both were running out — address space on one side, router memory on the other.

RFC 4632 replaced the implied boundary with an explicit one. Now that 400-host network takes a /23: 512 addresses, one routing entry, nothing wasted. The class of the address became irrelevant, which is why the "legacy class" field in the calculator is labelled as informational only.

Reading a prefix that is not on an octet boundary

/8, /16 and /24 are easy because they land exactly between octets. The interesting ones do not, and that is where people lose confidence. Take 192.168.4.0/22.

22 bits is two full octets (16) plus 6 bits into the third. So the first two octets are fixed at 192.168, and the third octet has its top 6 bits fixed and its bottom 2 free:

third octet:  000001 00
              └────┘ └┘
              fixed  free (2 bits → 4 values)

 4 = 000001 00 → 192.168.4.x
 5 = 000001 01 → 192.168.5.x
 6 = 000001 10 → 192.168.6.x
 7 = 000001 11 → 192.168.7.x

192.168.4.0/22 = 192.168.4.0 – 192.168.7.255

Two free bits in the third octet and eight in the fourth: 210 = 1,024 addresses. The block starts at 192.168.4.0 because 4 is the only value those six fixed bits allow, and the run of four third-octet values follows directly.

Why blocks must be aligned

There is no such thing as 192.168.5.0/22. The fixed bits of a /22 cannot produce a third octet of 5 as a starting point — 5 requires the bottom two bits to be 01, and those bits are supposed to be free.

This is the alignment rule: a block of size 2n can only begin at an address that is a multiple of 2n. A /22 spans 1,024 addresses, so it must start at 192.168.0.0, 192.168.4.0, 192.168.8.0, and so on.

Type 192.168.5.0/22 into the calculator and it will normalise to 192.168.4.0/22 and tell you it did — the same thing a router does, because the host bits simply are not part of the block's identity.

Alignment is also why converting an arbitrary range to CIDR usually needs several blocks rather than one.

IPv6 works identically

The only change is the width: 128 bits instead of 32, written as eight groups of four hex digits. 2001:db8::/48 fixes the first 48 bits and leaves 80 free, which is 280 addresses — about 1.2 septillion.

One convention is worth knowing. In IPv6 the lower 64 bits are the interface identifier, which hosts generate themselves, so /64 is the standard subnet size and prefixes longer than that break autoconfiguration. You are not subnetting to conserve space in IPv6; you are subnetting to organise it.

The three facts worth keeping

  1. The prefix length counts fixed bits from the left. Everything to its right is free.
  2. Block size is 2(32 − prefix) for IPv4, 2(128 − prefix) for IPv6.
  3. A block must start on a multiple of its own size.

Every number the CIDR calculator shows you — mask, wildcard, broadcast, host range, split tree — is a consequence of those three.

Try it on a real block