IPv4 CIDR aggregator

Summarize IPv4 networks into aggregated CIDR routes without expanding the address range.

Prefixes are normalized, sorted and aggregated where possible. Duplicates and fully covered prefixes are removed. The result remains limited to exactly the addresses provided.

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/24
TypeScript
const start = 0xC0A80100, end = 0xC0A801FF;
const prefix: number = 32 - Math.log2(end - start + 1);
console.log(prefix); // /24 when aligned
Python
import ipaddress
print(list(ipaddress.summarize_address_range(ipaddress.IPv4Address("192.168.1.0"), ipaddress.IPv4Address("192.168.1.255"))))  # 192.168.1.0/24
Java
int start=0xC0A80100, end=0xC0A801FF;
System.out.println(32 - (int)(Math.log(end-start+1)/Math.log(2))); // prefix length /24
C#
uint start=0xC0A80100, end=0xC0A801FF;
Console.WriteLine(32 - Math.Log2((double)end-start+1)); // prefix length /24

Learn about IP protocols