Skip to tool
ecech.
🌐 Network & IP

IP Range to CIDR, Using the Fewest Blocks That Cover Exactly That Range

192.168.1.5 to 192.168.1.10 is four CIDR blocks, not one. Firewalls want CIDR and people think in ranges, so here is the exact conversion.

Blocks needed

Addresses in range

Covered exactly?

no extras, none missed

CIDR blocks

Advertisement

How the calculation works

192.168.1.5 – 192.168.1.10  is four blocks, not one .5.6.7 .8.9.10 .5/32 .6/31 .8/31 .10/32 A /31 holds two addresses and must start on an even one. .5 is odd, so it can only take a /32. .6 and .7 pair up. .8 and .9 pair up. .10 is left alone at the end. Block size and starting boundary are locked together. That is why one block rarely fits.

How to Use This Tool

Enter a start and end address. You get the smallest set of CIDR blocks whose union is exactly that range — no address outside it, none inside it missed.

Why a range is not one block

A CIDR block is not an arbitrary interval. Its size is always a power of two, and it must start on a multiple of its own size. A /24 holds 256 addresses and can only begin at .0; a /31 holds two and can only begin at an even address.

So a range that starts on an odd address, or whose length is not a power of two, cannot be one block. The algorithm walks from the start and repeatedly takes the largest block that satisfies both constraints — correct boundary, and does not run past the end — then continues from where that block finished.

Both constraints matter. A block that is too large for the boundary would silently begin before your start address; one that overruns the end would include addresses after it. In a firewall rule either mistake means permitting traffic you did not intend, with nothing to warn you.

When a range does collapse to one block 10.0.0.0 – 10.0.0.255 10.0.0.0/24 one block 192.168.1.5 – .10 four blocks odd start, length 6 256 addresses starting at .0 fits perfectly. Six addresses starting at .5 does not.
Length a power of two, and starting on that boundary: both are required.

Reading the prefix length

The number after the slash counts the fixed leading bits, so a bigger number means a smaller block. A /32 is one address, /31 is two, /30 is four, /24 is 256. Each step down the number doubles the block. This is why counting blocks is a poor proxy for how much you are allowing: one /8 covers more than sixteen million addresses, and four /32s cover four.

Practical notes

  • Fewest blocks is not always what you want. A shorter rule list is easier to read, but if a device has a hard limit on rules, or you plan to remove part of the range later, a slightly longer decomposition along cleaner boundaries can be more maintainable.
  • /31 and /32 are legitimate. Older habits reserve network and broadcast addresses, but for firewall and routing rules these single- and double-address blocks are normal and correct.
  • Check the direction. If the end address is lower than the start, there is no range to cover. This tool reports that instead of silently producing something.
Advertisement

Frequently Asked Questions

Why does my IP range need more than one CIDR block?
Because a CIDR block's size is always a power of two and it must start on a multiple of that size. A range starting on an odd address, or with a length that is not a power of two, cannot satisfy both, so it has to be split. 192.168.1.5 to .10 needs four blocks for exactly this reason.
What is the fewest number of CIDR blocks for a range?
It is found by repeatedly taking the largest block that both starts on a valid boundary for its size and does not run past the end of the range, then continuing from where it finished. That greedy choice is provably minimal for a contiguous range, and it is what this tool computes.
Is a /31 or /32 block valid?
Yes. A /32 is a single address and a /31 is two. Older guidance about reserving network and broadcast addresses applies to host subnets, not to firewall rules or route entries, where single-address blocks are entirely normal.
Does a bigger prefix number mean a bigger block?
No, the opposite. The number counts fixed leading bits, so a larger number leaves fewer bits free and covers fewer addresses. A /32 is one address and a /8 is over sixteen million. This inversion catches people out regularly.
Can I just use a block that is slightly too big?
You can, but you should know what it costs. A block larger than your range includes addresses you did not intend to cover, which in a firewall rule means permitting traffic from hosts you never listed. That is why this tool never rounds outward — every block it emits is fully inside the range you gave.
Does this work for IPv6?
Not currently — this handles IPv4 ranges. The same boundary rules apply in IPv6, but the address space is large enough that ranges are usually expressed as blocks from the start rather than converted from arbitrary endpoints.

Related tools in Network & IP

Browse all Network & IP tools