DevTools Logo

CIDR Range Aggregator

CIDR Range Aggregator

Merge overlapping and adjacent IPv4/IPv6 ranges into the fewest CIDR blocks. Nothing leaves your browser.

Runs in your browser
Try an example

IPs, CIDRs and ranges

Paste an allow-list of IPv4 addresses, IPv6 addresses, CIDR blocks or start–end ranges. The aggregator converts each entry to an exact BigInt span, merges overlaps and adjacent spans, and emits the fewest CIDR blocks that cover the same addresses. Host bits are masked automatically, duplicates are counted, families are aggregated separately, and a coverage proof confirms that nothing was lost. Split-only mode normalises and sorts without supernetting; exclude mode subtracts a second list. Output tabs provide a plain CIDR list, nftables sets, iptables/ip6tables lines, AWS security group JSON and CSV.

  • Merge adjacent IPv4 blocks — Two adjacent /24 rules collapse into a single /23, halving the rule count.
  • Aggregate IPv6 fragments — IPv6 is aggregated independently of IPv4 and printed in RFC 5952 canonical form.
  • Host bits and duplicates — Host bits are masked to the network address and exact duplicates are counted and removed.
  • Firewall export — IPv4 goes to IpRanges and IPv6 to Ipv6Ranges, so the snippet matches the AWS security group schema.

Aggregated CIDRs

No aggregated CIDRs yet

Paste IPs, CIDRs or ranges, or load an example.

Examples

Adjacent blocks

Input
10.0.0.0/24
10.0.1.0/24
Output
10.0.0.0/23

Adjacency, not just overlap, is merged, halving the rule count.

IPv6 fragments

Input
2001:db8::/64
2001:db8:0:1::/64
Output
2001:db8::/63

The merged span is emitted as one aligned block in RFC 5952 form.

Exclude a subrange

Input
Ranges: 10.0.0.0/24
Exclude: 10.0.0.128/25
Output
10.0.0.0/25

Exclude mode subtracts the second list before summarisation.

About this tool

Allow-lists accrete rules: a /24 here, an overlapping /25 there, three years of one-off exceptions. This aggregator treats every entry as an exact [start, end] span of addresses, sorts the spans, merges overlaps and adjacency, then emits the fewest CIDR blocks that cover the same addresses. IPv4 and IPv6 are aggregated independently, so a v4 rule can never accidentally swallow a v6 range.

The arithmetic uses BigInt throughout: a /0 or a 128-bit IPv6 span is handled exactly, with no 32-bit truncation or floating-point rounding. A greedy largest-aligned-block pass turns each merged span into minimal CIDRs, and the coverage panel proves that the output set covers exactly the same addresses as the input set. Host bits set on a network address are masked with a notice, duplicates are counted, and invalid lines are reported with their line number while valid lines still aggregate.

Split-only mode skips supernetting: entries are masked, deduplicated and sorted, which suits policies that forbid shorter prefixes. Exclude mode subtracts a second list before summarisation. Results can be copied or downloaded as a plain CIDR list, nftables sets, iptables/ip6tables lines, AWS security group JSON with the correct IPv4/IPv6 keys, or CSV. All of this runs in the browser tab; no address list is uploaded.

What this tool does not do

  • IPv4 and IPv6 are aggregated separately; the output is a union of both families, never a cross-family supernet.
  • Split-only mode does not expand a range into individual addresses; it normalises and deduplicates CIDR entries only.
  • Exclusion matches exact address spans within the same family and does not resolve hostnames or DNS names.
  • Very large lists are held in browser memory and can slow the tab; no server-side or worker batching is performed.
  • The AWS snippet is a rule block to paste into an API call; it does not create or modify security groups by itself.

How to use this tool

  1. Paste the list

    Enter IPv4 or IPv6 addresses, CIDR blocks or start–end ranges, one per line or separated by commas or spaces. Firewall snippets and AWS JSON snippets can also be pasted back in.

  2. Read the stats

    Input rules, merged ranges, CIDR blocks, reduction percentage and duplicate count update as you type. A negative reduction means a single unaligned range needed several exact CIDRs.

  3. Pick a mode

    Leave Aggregate on to merge and supernet. Turn on Split-only to normalise without shorter prefixes, or Exclude ranges to subtract a second list.

  4. Copy a format

    Switch output tabs between CIDR list, nftables, iptables, AWS SG JSON and CSV, then copy or download the snippet.

  5. Check the proof

    Expand the coverage proof to confirm the emitted blocks cover exactly the same ranges; expand overlap groups to see which input lines merged.

Use cases

ACL cleanup

Reduce years of accumulated overlapping firewall rules to a minimal allow-list before a security review.

Cloud security groups

Consolidate cloud allow-lists, then paste the AWS SG JSON tab straight into an authorize-ingress call.

IPv6 rollout audit

Check that documented IPv6 fragments really are the minimal set and keep v4 and v6 rules separate.

Accepted input and output formats

FormExample / behavior
Bare IPv410.0.0.1 — treated as 10.0.0.1/32
IPv4 CIDR10.0.0.0/24 — prefix 0–32; host bits are masked with a notice
IPv4 range10.0.0.1-10.0.0.20 — inclusive start and end
IPv6 CIDR2001:db8::/32 — full or compressed notation, prefix 0–128
IPv6 range2001:db8::1-2001:db8::20 — inclusive start and end
ExportsPlain CIDR list, nftables ip/ip6 saddr sets, iptables/ip6tables lines, AWS IpPermissions JSON, CSV with decimal bounds

Inputs are separated by newlines, commas, semicolons or whitespace. IPv4-mapped IPv6 addresses stay in the IPv6 family; zone IDs such as %eth0 are stripped with a notice.

Common mistakes

Mistake:Assuming a range always becomes one CIDR.

Fix:An unaligned span such as 10.0.0.1-10.0.0.4 needs several exact blocks; the reduction stat can be negative, which is honest rather than an error.

Mistake:Putting IPv6 CIDRs into AWS IpRanges.

Fix:Use the AWS SG JSON tab: IPv4 goes to IpRanges/CidrIp and IPv6 goes to Ipv6Ranges/CidrIpv6, exactly as the API expects.

Mistake:Supernetting when policy forbids shorter prefixes.

Fix:Turn on Split-only mode; entries are still masked, sorted and deduplicated, but no /23 is emitted for two /24s.

Mistake:Expecting an excluded range to change the other address family.

Fix:Exclusion is applied per family; subtract IPv6 ranges with IPv6 ranges and IPv4 ranges with IPv4 ranges.

Frequently asked questions

What does aggregating CIDRs mean?

It means replacing many overlapping or adjacent network rules with the fewest CIDR blocks that cover exactly the same addresses. Each entry is converted to a numeric start–end span, overlapping spans are merged, and each merged span is split into the largest aligned blocks that fit. Nothing outside the original ranges is added.

Does it merge adjacent blocks as well as overlapping ones?

Yes. A span is merged with the next when the next start is at or before the current end plus one, so 10.0.0.0/24 and 10.0.1.0/24 become 10.0.0.0/23. A real gap, such as a missing 10.0.1.0/24, is preserved.

Is IPv6 supported?

Yes. Full, compressed and IPv4-embedded IPv6 forms are accepted, prefix bounds are 0–128, and output uses RFC 5952 canonical text. IPv6 is aggregated independently of IPv4: an IPv4-mapped IPv6 address stays an IPv6 span and never merges with a v4 rule.

Can it detect duplicates and invalid lines?

Exact duplicates are counted and removed before merging, and the stats card shows how many were found. Invalid entries are reported with their original line number while valid entries still aggregate. Host bits set on a network address are masked to the network with a notice rather than rejected.

Are the outputs valid for nftables, iptables and AWS security groups?

The nftables tab emits ip saddr and ip6 saddr sets, the iptables tab emits iptables lines for IPv4 and ip6tables lines for IPv6, and the AWS tab emits an IpPermissions JSON block with IPv4 CIDRs under IpRanges/CidrIp and IPv6 CIDRs under Ipv6Ranges/CidrIpv6. The CSV tab carries the CIDR, family and decimal start/end of each block.

What if my organisation forbids supernetting?

Turn on Split-only mode. Entries are still masked, sorted and deduplicated, but no shorter prefix is emitted: two /24s stay two /24s. This is also the right mode when you want a clean, ordered list rather than the smallest one.

What does Exclude ranges do?

Exclude mode takes a second list and subtracts it from the first before summarisation. For example, excluding 10.0.0.128/25 from 10.0.0.0/24 leaves 10.0.0.0/25. The subtraction is exact BigInt arithmetic and applies only within the same address family.

Why can the reduction percentage be negative?

The percentage compares the number of input rules with the number of output CIDR blocks. A single unaligned range such as 10.0.0.1-10.0.0.4 needs three CIDRs to express exactly, so the count grows. This is expected: the output is minimal for that span, not smaller than the input.

Is my IP list uploaded anywhere?

No. Parsing, aggregation, formatting and the coverage proof all run locally in this browser tab. Nothing is transmitted or stored on a server.

References & standards