Knowledge base

CIDR explained — prefixes, masks and route aggregation

Convert prefixes and masks, find block boundaries, split networks, and aggregate routes safely.

By the end of this guide, you will be able to convert a prefix to a mask, find a block's boundaries, and decide whether routes can be combined safely. For 192.0.2.130/26, you will find the block 192.0.2.128–192.0.2.191; in practical terms, the entered host address belongs to network 192.0.2.128/26. CIDR means Classless Inter-Domain Routing. It replaced fixed class A, B, and C boundaries with an explicit prefix length. RFC 4632 is a Best Current Practice covering allocation, prefix notation, and aggregation: combining specific routes into a shorter shared prefix.

Prefix, mask, and capacity

Every complete prefix octet contributes 255. In a partial octet, successive bit values are 128, 64, 32, 16, 8, 4, 2, and 1. Therefore /21 = 8 + 8 + 5 and its mask is 255.255.248.0. To reverse the conversion, count the one bits. A non-contiguous mask with a one after the first zero has no single CIDR prefix.

An IPv4 block contains 2^(32 − prefix) addresses, so /26 contains 64. The CIDR converter also shows the binary mask and wildcard.

Worked example: 192.0.2.130/26

  1. The /26 mask is 255.255.255.192, giving an increment of 64.
  2. Last-octet boundaries are 0, 64, 128, and 192.
  3. 130 falls within 128–191.
  4. The canonical block is 192.0.2.128/26, broadcast is 192.0.2.191, conventional hosts are .129–.190, and wildcard is 0.0.0.63.

RFC 5737 reserves 192.0.2.0/24 for documentation. In 10.20.37.200/20, the mask is 255.255.240.0, the third-octet increment is 16, and the block spans 10.20.32.0–10.20.47.255.

Splitting into equal subnets

Splitting 192.0.2.0/24 into /26s borrows 2 bits and creates 2^2 = 4 blocks: .0/26, .64/26, .128/26, and .192/26. Each has 64 addresses. Generate the table with the equal-subnet tool; use VLSM when sizes differ.

Aggregation and alignment

Those four /26s exactly cover 192.0.2.0/24. Two blocks combine into a prefix one bit shorter only if they have equal size, are adjacent, and the pair begins on the larger block's boundary. 192.0.2.64/26 and 192.0.2.128/26 touch but do not form a /25; their common /24 also covers additional addresses.

RFC 4632 calls for a discard route for an advertised aggregate so traffic to a missing more-specific route does not loop through a less-specific route. The route summary tool distinguishes exact coverage from a common supernet that contains gaps.

Longest-prefix match

For 192.0.2.140, routes 0.0.0.0/0, 192.0.2.0/24, and 192.0.2.128/25 all match. The router selects /25 because it has the most matching leading bits. Other protocol and routing-table rules decide between routes of equal prefix length.

Wildcards and special prefixes

For a contiguous subnet mask, the wildcard is its bitwise complement; /26 yields 0.0.0.63. ACL syntaxes may also accept non-contiguous wildcards that do not describe one CIDR block. /0 covers every IPv4 value and serves as a default route, /31 provides two point-to-point endpoints under RFC 3021, and /32 describes one address.

Checklist before using the result

  • Normalize a host address to the real block boundary before writing a route.
  • Check mask continuity and alignment before aggregation; adjacency alone is insufficient.
  • Treat capacity as the number of values in a block, not a promise of reachable devices.
  • Check the address purpose in the IANA registry independently of prefix length.

A little network lab

Exact aggregation with a gap left out

You have 198.51.100.0/26, 198.51.100.64/26, and 198.51.100.128/27. Shorten the route list without including the unallocated end of the /24.

Example result198.51.100.0/25 + 198.51.100.128/27Open example in calculator
  1. The two /26s cover .0–.63 and .64–.127. They contain 128 addresses and start at a /25 boundary, so they merge into 198.51.100.0/25.

  2. The remaining /27 covers .128–.159. Its sibling .160/27 is absent, so it cannot merge. The result must retain a second entry.

  3. The exact result contains 128 + 32 = 160 addresses. A single covering /24 would contain 256 and add the 96 addresses .160–.255.

Your turn

What changes if you add 198.51.100.160/27?

Show answer and explanation

The two /27s merge into 198.51.100.128/26. The result is .0/25 and .128/26, totalling 192 addresses. The .192/26 is still absent, so an exact /24 is impossible.

Official documents

Standards & sources

Sources checked:

The date refers to checking the listed documents and registries, not endorsement by their authors. Calculation assumptions and limits appear with the result. How we prepare the material.