DEV Community

NetEngineerLab
NetEngineerLab

Posted on

CIDR Route Summarization: Avoiding Accidental Prefix Leaks

Aggregating routes reduces BGP table size and keeps flapping edge links from rippling through a core network. The catch is that CIDR summarization follows binary power-of-two boundaries, not human numbering habits. Pick the wrong summary prefix and you end up advertising subnets that belong to another site—or another organization.

Why 10.20.3.0/24 and 10.20.4.0/24 do not fold into a /23

Look at two adjacent /24 networks: 10.20.3.0/24 and 10.20.4.0/24. Because .3 ends right where .4 begins, engineers routinely assume they collapse into a single /23.

Write the third octet in binary to see why they cannot:

10.20.3.0/24  -> 00000011  (belongs to 10.20.2.0/23, covering .2 and .3)
10.20.4.0/24  -> 00000100  (belongs to 10.20.4.0/23, covering .4 and .5)
Enter fullscreen mode Exit fullscreen mode

In RFC 4632 CIDR alignment, a /23 boundary can only start on an even third octet (0, 2, 4, 6, ...). Because 10.20.3.0/24 sits in the 10.20.2.0/23 block and 10.20.4.0/24 sits in the 10.20.4.0/23 block, they are not a matching pair inside one /23 parent.

If you force a single covering CIDR prefix over both networks, the third octets only agree on their first five bits (00000xxx):

10.20.0.0/21  -> covers 10.20.0.0 through 10.20.7.255
Enter fullscreen mode Exit fullscreen mode

That single summary sweeps in six extra /24 networks (10.20.0.0/24, .1, .2, .5, .6, and .7)—1,536 unlisted IP addresses. If .2 or .5 lives in a different VPC, data center, or customer tenant, summarizing .3 and .4 into 10.20.0.0/21 pulls their traffic toward the wrong router.

Exact route aggregation leaves 10.20.3.0/24 and 10.20.4.0/24 as two separate prefixes rather than inventing a broader supernet.

How clean pairs and redundant prefixes actually fold

Compare that with a branch prefix list containing four entries:

10.20.0.5/24
10.20.1.0/24
10.20.1.128/25
10.20.3.0/24
Enter fullscreen mode Exit fullscreen mode

Walking through exact CIDR reduction step by step:

  1. Normalize host bits: strip any non-zero host bits first so 10.20.0.5/24 becomes 10.20.0.0/24.
  2. Drop covered subnets: 10.20.1.128/25 is already contained inside 10.20.1.0/24, so advertising it separately adds clutter unless you deliberately need a more-specific exception for traffic engineering.
  3. Fold matching sibling pairs: 10.20.0.0/24 (00000000) and 10.20.1.0/24 (00000001) are the two halves of 10.20.0.0/23, so they collapse cleanly into one /23.
  4. Leave non-aligned leftovers alone: 10.20.3.0/24 has no .2 partner, so it stays 10.20.3.0/24.

Result: two exact routes (10.20.0.0/23 and 10.20.3.0/24) covering every listed address and zero unlisted addresses. The same binary pairing applies to IPv6. Because the 48th bit flips from 0 to 1 between 2001:db8:0::/48 and 2001:db8:1::/48, those two site blocks fold cleanly into 2001:db8::/47. By contrast, 2001:db8:1::/48 and 2001:db8:2::/48 sit in different /47 parents, so exact summarization keeps them separate instead of widening to 2001:db8::/46.

Setting a minimum prefix length for BGP policies

Exact binary folding is not always what you want across autonomous system boundaries. On the public IPv4 internet, networks commonly filter announcements longer than /24—and sometimes you intentionally stop aggregation at /24 (or /48 for IPv6) so two adjacent regional /24 blocks do not fold into a /23 that breaks per-POP failover or RPKI Route Origin Authorization (ROA) matching.

Putting a shortest-allowed prefix floor in place (such as 24 for IPv4) still removes duplicate or covered /25 and /26 entries while keeping each /24 independent.

Checking aggregates before pushing router config

Route summarization arithmetic only knows about address blocks, not physical topology. Before turning a summarized list into a BGP aggregate-address statement or cloud VPC route-table entry, verify two things:

  • Every address covered by a shorter aggregate actually routes through that router—or has a discard/null route installed for unused sub-blocks so packets destined to unallocated IPs do not bounce between your core and an upstream default route in a forwarding loop.
  • No more-specific exception prefixes that you still need for active-active ingress were silently swallowed by a broader block.

I maintain NetEngineerLab, where the Route Summarization Calculator normalizes IPv4 and IPv6 prefixes separately, collapses exact sibling pairs, removes redundant covered routes, and lets you set a shortest-allowed prefix floor before you touch router configuration.

Top comments (0)