
IPv4 CIDR aggregator
Summarize IPv4 networks into aggregated CIDR routes without expanding the address range.
A minimal aggregate is possible only when complete sibling blocks are present.
Method and assumptions
Method version 1.0.0 · Updated
Aggregate IPv4 prefixes
Formula: Merge adjacent sibling CIDR blocks without including addresses absent from the entered prefixes.
Prefixes are normalized, sorted and aggregated where possible. Duplicates and fully covered prefixes are removed. The result remains limited to exactly the addresses provided.
- prefixes
- IPv4 prefixes (one per line or comma-separated)
From 1 to 32 valid IPv4 prefixes with lengths from /0 to /32. Aggregation does not cover addresses outside the entered prefixes.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
const start = 0xC0A80100, end = 0xC0A801FF;
let prefix = 32 - Math.log2(end - start + 1);
console.log(prefix); // 192.168.1.0/24TypeScript
const start = 0xC0A80100, end = 0xC0A801FF;
const prefix: number = 32 - Math.log2(end - start + 1);
console.log(prefix); // /24 when alignedPython
import ipaddress
print(list(ipaddress.summarize_address_range(ipaddress.IPv4Address("192.168.1.0"), ipaddress.IPv4Address("192.168.1.255")))) # 192.168.1.0/24Java
int start=0xC0A80100, end=0xC0A801FF;
System.out.println(32 - (int)(Math.log(end-start+1)/Math.log(2))); // prefix length /24C#
uint start=0xC0A80100, end=0xC0A801FF;
Console.WriteLine(32 - Math.Log2((double)end-start+1)); // prefix length /24