Skip to content
[menu][close]

FOUNDRYNETNo. 001SEPTEMBER 2026ROUTING

Checking AI-Generated Subnet and ACL Math Before You Use It

Ask a chatbot to carve a /22 into VLAN subnets and the answer will look perfect. Often one boundary is off by a block, or a wildcard mask covers twice the range. The fix is not to stop asking, but to check the arithmetic with something that cannot hallucinate.

Duotone plate of a thick off-white path hopping between square router nodes on near-black, with one alternative branch peeling away in hot pink.
PlateNetwork Routing Guide
On this page

01 Why models slip on subnet arithmetic

Language models predict text, and subnet plans are text that looks the same whether the numbers are right or wrong. The common failures are consistent: a subnet that starts on a boundary its prefix length does not allow, two subnets that overlap by one block, a broadcast address given as usable, and wildcard masks that are the netmask rather than its inverse. Each is easy to miss in review because the output is well formatted. This procedure, in the routing section, checks the numbers with tools. It complements the broader method for verifying AI-written configurations.

02 The check, step by step

  1. List every prefix

    Extract each network and prefix length from the plan into one list, including the parent block it was carved from.

  2. Recompute with a library

    Parse each prefix with a CIDR library, such as the standard ipaddress module in Python, in strict mode. A strict parser rejects a network address that is not aligned, which catches the most common error immediately.

  3. Check containment and overlap

    Confirm each subnet is inside the parent block and that no two overlap. Sort by network address and compare each end with the next start.

  4. Recompute sizes and usable ranges

    For each subnet, compute the number of addresses, the first and last usable host and the broadcast address, and compare with the plan. Plans often claim one extra usable host.

  5. Convert wildcard masks back

    For each ACL entry, turn the address and wildcard back into a range and compare it with what the entry was meant to match. A netmask pasted where a wildcard belongs matches far more than intended.

  6. Test with addresses

    Feed the ACL or firewall rule the first and last address of each intended range and one address just outside, in a lab device or a policy analysis tool, and confirm each result.

Strict parsing catches a misaligned subnet, illustrative
$ python3 -c "import ipaddress; ipaddress.ip_network('10.20.7.0/23')"
ValueError: 10.20.7.0/23 has host bits set
$ python3 -c "import ipaddress; print(ipaddress.ip_network('10.20.7.0/23', strict=False))"
10.20.6.0/23

The first command fails because a /23 must start on an even third octet; the second shows the network the plan actually describes. In a VLAN plan, that single error puts two VLAN subnets and their gateways in the same address space.

03 The errors worth looking for

All five appear regularly in generated plans.
ErrorExampleHow the check catches it
Misaligned network10.20.7.0/23Strict parse fails: host bits set
Overlap10.20.4.0/23 and 10.20.5.0/24Sorted comparison: second starts inside first
Wrong usable countA /27 listed with 32 hostsRecomputed: 30 usable plus network and broadcast
Netmask as wildcard0.0.0.255 intended, 255.255.255.0 writtenConverted range covers the wrong bits entirely
Reserved space usedDocumentation range 192.0.2.0/24 in productionCheck against the special-purpose registry

04 Keeping the check in the change process

Make the recomputation part of review, not an optional extra: attach the tool output to the change ticket so the reviewer sees the numbers checked, not just the plan. The same principle runs through peer review for AI-assisted network changes: generated work is welcome, unverified generated work is not.

RULE OF THUMB

If a number decides where a packet goes, a tool must have computed it or checked it. A model may have suggested it.

05 Questions

Can I trust AI chatbots with subnetting?

Use them for a first draft, never as the final answer. Recompute every prefix with a CIDR library or calculator and check alignment, containment and overlap.

How do I check a subnet is aligned?

Parse it strictly with a CIDR library. The network address must be a multiple of the block size; a strict parser raises an error when host bits are set.

What is a wildcard mask?

The bitwise inverse of a netmask, used in many ACL syntaxes. 0.0.0.255 matches a /24; writing the netmask 255.255.255.0 there matches something entirely different.

Which address ranges should never appear in production plans?

Documentation ranges such as 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24 (RFC 5737), and other special-purpose blocks listed in the IANA registry described by RFC 6890.

How do I test an ACL before deployment?

Run the first and last address of each intended range and one just outside through a lab device or a configuration analysis tool, and compare the results with the intent.