Can an LLM Correctly Aggregate CIDR Routes? A Route-Summarization Test
Small, real, reproducible test run 16 November 2026 - three route-aggregation cases and one deterministic ground-truth script, not a benchmark claim. The raw prompt and the model's raw reply are linked in Sources. Disclosure: this article was drafted with AI assistance; the test itself was run against a second, independent model instance so the author's own writing didn't also grade its own homework.
The first five tests in this series covered BGP best-path, longest-prefix-match, LDP/LFIB construction, OSPF SPF and ACL ordering. This sixth test goes back to basic address math, but the kind that trips up humans just as often as it would trip up a careless model: route summarization. Given a set of subnets a router actually originates, what is the minimal, numerically correct supernet (or set of supernets) that covers exactly those subnets - no more, no less? "No more" matters operationally: a supernet that is too wide claims reachability for address space the router doesn't actually own, which can black-hole traffic for someone else's subnet sitting inside the same block. "No less" matters for table size: failing to spot a legitimate aggregation opportunity bloats the routing table for no reason. Does a model actually check bit-boundary alignment before proposing a supernet, or does it eyeball "these four /24s are consecutive numbers" and jump straight to a single summary that happens to be wrong?
- Three independent CIDR aggregation cases were given cold to a second, independent model instance: (A) 4 contiguous, boundary-aligned /24s that correctly collapse to one /22; (B) 4 contiguous /24s that are numerically consecutive but NOT aligned to a /22 boundary, so no single supernet is correct; (C) 2 non-adjacent /24s separated by a subnet the router does not originate, where summarizing at all would be wrong.
- 3 for 3 cases correct against an independently computed ground truth (Python's
ipaddress.collapse_addresses()), including both traps: the misaligned block correctly came back as three routes, not one wrong /22, and the non-adjacent pair correctly came back unsummarized. - Case B is the sharpest trap: 172.16.9.0-172.16.12.0/24 "look" like a clean four-block run, but a /22 only aligns on blocks whose third octet is a multiple of 4 (8, 12, 16...) - this set straddles two different /22s, so the real minimal aggregation is 172.16.9.0/24 + 172.16.10.0/23 + 172.16.12.0/24, three routes, not one.
- Case C is the correctness trap, not just a math trap: 10.5.2.0/24 and 10.5.4.0/24 are numerically "close" but 10.5.3.0/24 in between belongs to someone else - any supernet wider than /24 for either one would incorrectly imply this router can reach (or should receive) that middle block.
- Same actionable conclusion as the first five tests: diff a proposed summary route against a deterministic collapse computed from the actual advertised subnet list before pushing it into an aggregate-address or summary-address statement - a wrong supernet here isn't just inefficient, it's a real black-holing or route-leak risk.
Why route summarization is a good test · The test: 3 cases, 2 deliberate traps · What came back · No citations, same pattern as LPM/SPF/ACL · Six tests, one verification pattern · FAQ
Why route summarization is a good test
Route summarization (aggregation) replaces several specific routes with one shorter-prefix supernet route, provided the supernet exactly covers the specific routes and nothing else. The catch is bit-boundary alignment: a /22 supernet can only start on a third-octet value that's a multiple of 4 (0, 4, 8, 12...), a /23 only on an even value, and so on. Four /24s that are numerically consecutive integers are not automatically a valid /22 - they also have to sit entirely within one aligned /22 block. This is exactly the kind of mistake that is easy to make by eyeballing a list of subnets rather than checking the binary boundary, and it's operationally dangerous in a specific way: pushing a too-wide aggregate-address or summary-address statement doesn't just waste table space, it can advertise reachability for address space that belongs to a different router, a different customer, or nobody at all - a real route-leak / black-hole risk, not a cosmetic one.[1]
The test: 3 cases, 2 deliberate traps
We built three independent summarization cases and asked for the minimal set of CIDR supernet routes that covers exactly the advertised subnets, no more:
Case A (aligned, should collapse to ONE route): 192.168.4.0/24, 192.168.5.0/24, 192.168.6.0/24, 192.168.7.0/24 Case B (consecutive but MISALIGNED - trap): 172.16.9.0/24, 172.16.10.0/24, 172.16.11.0/24, 172.16.12.0/24 Case C (numerically close but a GAP subnet belongs to someone else - trap): 10.5.2.0/24, 10.5.4.0/24 (10.5.3.0/24 is NOT ours)
Case A is the control: 192.168.4.0 through 192.168.7.0 sit entirely inside the aligned block 192.168.4.0/22 (4 is a multiple of 4), so a single /22 is both correct and minimal. Case B looks identical in shape - four consecutive /24s - but 172.16.9.0 through 172.16.12.0 straddle the boundary between the 172.16.8.0/22 block (8-11) and the 172.16.12.0/22 block (12-15); neither of those /22s matches the advertised set exactly, one would under-cover and the other would over-cover by claiming 172.16.13.0-172.16.15.0/24 which isn't ours. Case C tests something different: 10.5.2.0/24 and 10.5.4.0/24 are two hops apart in the third octet, but 10.5.3.0/24 sitting between them is explicitly stated as not advertised by this router - so no supernet wider than /24 for either one is valid, regardless of how "close" the numbers look.
The three cases and the instruction (return the minimal correct supernet set, JSON only, no explanation) were sent cold to a second, independent model instance with no hints about which case was a trap. Ground truth was computed independently with Python's ipaddress.collapse_addresses(), not hand-checked (ops/cidr_test_calc.py → ops/cidr_test_ground_truth.json).
What came back
| Case | Correct minimal summary (ground truth) | Why it's a trap (or not) | Model's answer | Match? |
|---|---|---|---|---|
| A - 4 aligned /24s | 192.168.4.0/22 | Control case: naturally boundary-aligned, one correct supernet | 192.168.4.0/22 | Yes |
| B - 4 consecutive but misaligned /24s | 172.16.9.0/24, 172.16.10.0/23, 172.16.12.0/24 | Trap: "looks" like one /22 but straddles two different aligned /22 blocks - no single supernet is correct, needs three routes | 172.16.9.0/24, 172.16.10.0/23, 172.16.12.0/24 | Yes |
| C - 2 non-adjacent /24s, gap owned elsewhere | 10.5.2.0/24, 10.5.4.0/24 (unsummarized) | Trap: summarizing at all would falsely claim reachability for the unowned 10.5.3.0/24 in between | 10.5.2.0/24, 10.5.4.0/24 | Yes |
Three for three, including both traps. The model did not take the bait of pattern-matching "four consecutive /24 numbers = one /22" in case B, and it correctly refused to invent a wider supernet in case C just because the two /24s were numerically close - it respected that the router doesn't own the subnet in between.
No citations, same pattern as LPM/SPF/ACL
Like the longest-prefix-match, OSPF SPF and ACL-ordering tests, this reply carried zero citation links (the model returned exactly the requested bare JSON, as asked). The underlying rule it had to apply correctly - bit-boundary alignment for supernetting, and never summarizing across address space you don't originate - is well-documented CIDR/BGP aggregation practice[1][2], but like the earlier closed-form tests, applying it to a specific, self-contained set of inputs didn't pull in an external source in the reply itself.
Six tests, one verification pattern
Six tests now, six different kinds of network-engineering judgment - BGP best-path (policy/attribute comparison), longest-prefix-match (IP forwarding arithmetic), LDP/LFIB construction (MPLS reserved-label semantics), OSPF SPF (link-state graph arithmetic), ACL ordering (sequential rule-list evaluation), and now CIDR aggregation (bit-boundary alignment plus ownership correctness) - and the same operational conclusion every time: a model's answer is either demonstrably right or demonstrably wrong against a deterministic ground truth, and a wrong answer carries exactly the same confident tone as a right one. Route summarization is worth flagging separately because a wrong answer here is not merely "an inefficient routing table" - it is a potential route leak or black hole for address space the aggregating router does not actually own, which is a correctness and security property, not just a tidiness one.
| Step | Who does it | How you check it |
|---|---|---|
| 1. Subnet list / config text → structured input | LLM | Schema check against the actual advertised-subnet list |
| 2. Forwarding/policy decision (BGP best-path, LPM, LFIB swap/pop/drop, SPF path, ACL match, or CIDR aggregation) | LLM, or your own code | Diff against a deterministic script encoding the actual algorithm - Dijkstra, CIDR containment, reserved-label logic, first-match-wins list walk, or bit-boundary collapse (e.g. Python's ipaddress.collapse_addresses()) |
| 3. Present the result | LLM, fed the already-verified decision | Spot-check the presented supernet(s) exactly match the verified output - specifically check nothing wider than what was actually advertised snuck in |
For the earlier tests in this series, see Can an LLM Read a BGP Table? A Practical Test With Real Router Output, Can an LLM Do Longest-Prefix-Match Routing Lookups?, Can an LLM Build an MPLS LFIB from LDP Label Bindings?, Can an LLM Compute an OSPF SPF Tree? A Dijkstra Hands-On Test, and Can an LLM Evaluate a Cisco ACL in Order?. For keeping an AI agent bounded and read-only around real device state more generally, see our piece on a read-only network change reviewer.
Frequently asked questions
Can an LLM correctly compute CIDR route aggregation?
In our small test (three independent cases, one aligned control and two deliberate traps), a model correctly identified the minimal valid supernet set for all three cases against an independently computed ground truth, including refusing to produce a single /22 for a misaligned block and refusing to summarize across a subnet it did not own. That's a good result on a small, controlled sample, not a benchmark covering large real-world aggregation tables, VLSM-heavy address plans, or IPv6 prefixes.
Why can't four consecutive /24 subnets always be summarized into one /22?
A /22 supernet must start on a third-octet value that is a multiple of 4 (0, 4, 8, 12, ...). Four /24s that are consecutive integers (e.g. .9, .10, .11, .12) can straddle the boundary between two different aligned /22 blocks, in which case no single /22 covers exactly that set - the minimal correct aggregation is a mix of a /23 and two standalone /24s instead.
Why is summarizing across a subnet you don't own risky?
A supernet route advertises reachability for the entire address range it covers, not just the specific subnets that motivated it. If that range includes a subnet owned and originated by a different router (or a different organization), the overly broad aggregate can black-hole traffic meant for that subnet or create a conflicting, higher-preference path to it - a real routing-correctness and route-leak risk, not just a table-size inefficiency.
How should you verify an LLM's proposed route summary before deploying it?
Run the actual advertised-subnet list through a deterministic collapse function (e.g. Python's ipaddress.collapse_addresses()) and diff the result against the model's proposed supernet(s) before pushing anything into an aggregate-address or summary-address statement. Specifically check that the proposed supernet's address range doesn't exceed the union of the subnets you actually originate.
Sources
Checked 16 November 2026.
- Cisco, "Understand Route Aggregation in BGP" (aggregate-address, boundary alignment, as-set/summary-only) - cisco.com/.../5441-aggregation.html
- IETF, RFC 4632 "Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan" - datatracker.ietf.org/doc/html/rfc4632
- Ground-truth script and raw model reply:
ops/cidr_test_calc.py,ops/cidr_test_ground_truth.json, full exchange logged inops/szafa_log.md(2026-11-16).
Try it: CIDR to IP Range - free, runs in your browser.
Related reading
- Can an LLM Elect an STP Root Bridge and Port Roles? A Hands-On 802.1D Test
- Can an LLM Get Route Redistribution Right? Administrative Distance, OSPF E1 vs E2, and the Seed-Metric Trap
- Can an LLM Get VRRP/HSRP Master Election Right? Priority Ties, Preemption, and Tracking Decrements
- Can an LLM Run a Token-Bucket QoS Policer? CIR/CBS Conform/Exceed Decisions
- Can an LLM Reason About BGP Route-Reflector Loop Prevention? Blind Test, Corrected to 5/5
- Can an LLM Pick the Right EIGRP Feasible Successor? DUAL's Strict-Inequality Trap
Comments
Post a Comment