Reading a Small CIDR Prefix
A prefix length gives the number of leading address bits shared by addresses in that block.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Work an IPv4 example
The documentation prefix 192.0.2.0/24 fixes its first 24 bits and leaves eight bits varying. That block contains 256 addresses. Particular network rules may reserve some. Unsigned bit fields determine the number of possible suffixes.
Distinguish route matching
An address like 192.0.2.9 belongs to that prefix. If several forwarding entries match, a router commonly selects the most specific one under the forwarding model. See longest prefix matching.[1][2]
Compute the boundary of a small address block
The prefix 192.0.2.64/26 fixes the top twenty-six IPv4 bits. Six remaining bits permit sixty-four addresses, so the block spans 192.0.2.64 through 192.0.2.127. This is a count of addresses in the mathematical block. See masking with bitwise AND.
Last octet mask: 11000000 = 192
64 in binary: 01000000
127 in binary: 01111111, same top two bits
128 in binary: 10000000, outside
Separate membership from host assignment conventions
Some addresses have special roles under particular network rules. A prefix calculation alone does not establish whether a given host uses an address. Test the first address, last address and next block boundary.