Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Smallest CIDR Prefix Covering the Range
/24
covers 256 addresses
Addresses in range 256
CIDR block size (2^n) 256
Start IP (integer) 3,232,235,520
End IP (integer) 3,232,235,775

What is the IP Range to CIDR Calculator?

This tool takes a start and end IPv4 address and returns the smallest single CIDR block (a /prefix) large enough to cover the entire range. CIDR (Classless Inter-Domain Routing) notation expresses a block of addresses as a base address followed by a slash and a prefix length, such as 192.168.0.0/24. It is universal to IPv4 and works in any country or network.

How to use it

Enter the first address of your range in Start IP Address and the last address in End IP Address, then submit. The calculator converts both addresses to 32-bit integers, counts the addresses between them, and computes the prefix length of the smallest power-of-two block that contains them all.

The formula explained

Each IPv4 address maps to a 32-bit integer. The number of addresses in the range is \(\text{count} = \text{end} - \text{start} + 1\). A CIDR block always holds a power-of-two number of addresses: a \(/n\) block holds \(2^{32-n}\) addresses. To cover \(\text{count}\) addresses we round up to the next power of two, $$\text{blockSize} = 2^{\lceil \log_2(\text{count}) \rceil}$$ then the prefix is $$32 - \log_2(\text{blockSize})$$

Advertisement
Illustration of binary address bits split into a fixed network prefix and variable host portion
The prefix length marks where the fixed network bits end and host bits begin.
Diagram showing a continuous IP address range from start to end broken into aligned CIDR blocks
A start-to-end range is covered by the smallest set of aligned CIDR blocks.

Worked example

Range 192.168.0.0 to 192.168.0.255. As integers these are 3,232235520 and 3,232235775, so \(\text{count} = 256\). Since \(256 = 2^8\), the block size is 256 and the prefix is $$32 - 8 = 24$$ giving /24.

FAQ

Does the result always align to a CIDR boundary? The prefix is the smallest that fits the count, but a single CIDR block must also be address-aligned. If your start address is not on that boundary, the range may require multiple smaller blocks.

What if I enter them backwards? The calculator automatically swaps the start and end if the end is smaller.

Is this for IPv6 too? No — this tool covers IPv4 (32-bit) ranges only.

Last updated: