Read a prefix as fixed bits
How to interpret CIDR prefixes, test address membership, and select correctly aligned blocks for allowlists without including unintended source addresses. · associate
Classless Inter-Domain Routing (CIDR) describes an address range using an address and a prefix length, such as 203.0.113.0/24. IPv4 addresses have 32 bits. The /24 prefix fixes the first 24 bits and leaves 8 bits free to vary.
The address count is 2 raised to the number of remaining bits: a /24 contains 256 addresses, while a /28 contains 16. A larger prefix number means a smaller range. A /32 matches one IPv4 address; 0.0.0.0/0 matches every IPv4 address.
These are counts of addresses matched by a CIDR, not counts of assignable workload addresses in a subnet. IPv6 uses the same prefix principle with 128 bits; one IPv6 address is a /128.
| IPv4 prefix | Fixed bits | Variable bits | Addresses matched |
|---|---|---|---|
| /24 | 24 | 8 | 256 |
| /28 | 28 | 4 | 16 |
| /32 | 32 | 0 | 1 |
| /0 | 0 | 32 | All IPv4 addresses |