IP Range Calculator

Convert an arbitrary IPv4 range into exact CIDR blocks, with counts and the covering block.

What does this calculator do?

An address range such as 192.168.1.10 to 192.168.1.200 rarely lines up with a single CIDR block, because CIDR blocks must be aligned and power-of-two sized. This calculator gives you both answers and keeps them clearly apart: the exact CIDR decomposition, which is the shortest list of blocks that covers the range and nothing else, and the smallest single covering CIDR, which is one block but usually contains extra addresses outside your range. It also converts both endpoints to their 32-bit integer values, which is what firewall and database range comparisons use. All values are exact. Everything is computed in your browser from the values you type. Nothing is looked up on the network — there is no ping, no DNS query, no WHOIS and no geolocation.

Formula

Addresses are treated as unsigned 32-bit integers; the decomposition repeatedly takes the largest aligned block that starts at the current address without overrunning the end.

startNumeric = a×2^24 + b×2^16 + c×2^8 + d
totalAddresses = endNumeric − startNumeric + 1
block at start = largest aligned power-of-two block ≤ remaining addresses
coveringCidr = longest prefix where (start AND mask) = (end AND mask)

How to use it

Enter the first and last address of the range in dotted-decimal form; the range is inclusive of both. The start must not be greater than the end, or the calculation is rejected. Use the exact decomposition when you need firewall or routing entries that match only your range, and the covering block when a single summarised prefix is acceptable — check its address count first.

Worked example

From 192.168.1.10 to 192.168.1.200: the numeric bounds are 3,232,235,786 and 3,232,235,976, so the range holds 191 addresses. The exact decomposition needs 8 blocks — 192.168.1.10/31, .12/30, .16/28, .32/27, .64/26, .128/26, .192/29 and .200/32. The smallest single covering block is 192.168.1.0/24, but it holds 256 addresses, so it includes 65 addresses that are not in your range.

Formula version1.0.0
FormulastartNumeric = a×2^24 + b×2^16 + c×2^8 + d totalAddresses = endNumeric − startNumeric + 1 block at start = largest aligned power-of-two block ≤ remaining addresses coveringCidr = longest prefix where (start AND mask) = (end AND mask)

Frequently asked questions

Why does my range need so many CIDR blocks?

Every CIDR block must start on an address that is a multiple of its own size. A range that starts or ends off that alignment has to be built from progressively larger blocks, which is why an arbitrary 191-address range can take 8 of them.

When should I use the covering CIDR instead?

Only when the extra addresses are harmless — for example when the surrounding block is yours anyway. For a deny rule or a public allow-list, the extra addresses are a real change in scope, so use the exact decomposition.

What are the numeric start and end for?

They are the addresses as unsigned 32-bit integers. Storing ranges as integers makes membership tests a simple numeric comparison, which is how many databases, geo-IP tables and firewalls index address ranges.

Sources

Related calculators

Last updated: 2026-08-10 · v1.0.0 · Report an error