IP Range to CIDR
Turn a start and end address into the fewest CIDR blocks that cover it.
What you provide
Result
8 CIDR blocks cover 191 addresses
Arbitrary ranges rarely fall on prefix boundaries, so 8 blocks is the smallest exact cover rather than a limitation of the tool. If the list is long, consider whether the range can be widened slightly to the next clean boundary. One /22 is easier to maintain than eleven mixed blocks, provided the extra addresses it takes in are genuinely yours to include.
192.168.1.10/31 192.168.1.12/30 192.168.1.16/28 192.168.1.32/27 192.168.1.64/26 192.168.1.128/26 192.168.1.192/29 192.168.1.200/32
- Range
- 192.168.1.10 – 192.168.1.200
- Addresses
- 191
- CIDR blocks needed
- 8
- 192.168.1.10/31
- 2 addresses
- 192.168.1.12/30
- 4 addresses
- 192.168.1.16/28
- 16 addresses
- 192.168.1.32/27
- 32 addresses
- 192.168.1.64/26
- 64 addresses
- 192.168.1.128/26
- 64 addresses
- 192.168.1.192/29
- 8 addresses
- 192.168.1.200/32
- 1 addresses
What this cannot tell you
- IPv4 only. IPv6 ranges follow the same principle but use 128-bit arithmetic that this tool does not perform.
- It converts a range into blocks. It does not check whether those blocks are routable, allocated to you, or safe to put in a rule.
Take this with you
How this calculation works
The conversion works greedily from the low end. At each step it takes the largest block that both starts on a boundary the current address can legally begin and does not run past the end of your range, then moves on. That produces the smallest possible set of blocks, which matters in practice because every extra block is another firewall rule, another route entry and another line for somebody to maintain later.
What the results mean
- CIDR blocks needed
- How many prefixes it takes to cover the range exactly. One is the tidy case and means the range happens to align with a prefix boundary.
- Addresses per block
- The size of each block, always a power of two. This is why arbitrary ranges need several blocks rather than one.
- The block list
- Ready to paste into a firewall, an allow list or a route table. The order is low to high.
Common problems and fixes
- The list is much longer than expected
- That is the range rather than the tool. A range like 10.0.0.1 to 10.0.0.254 needs many blocks because it starts one address above a boundary and ends one below the next, and neither end can be expressed as a single prefix. Widening the range slightly to 10.0.0.0 to 10.0.0.255 collapses it to one /24, which is worth doing when the extra two addresses are yours anyway.
- A firewall rejects one of the blocks
- Some devices insist the address before the slash is the network address of the block rather than any address inside it. Every block this tool produces is already properly aligned, so if one is rejected, check whether the device wants a mask in dotted-quad form instead, or whether it disallows very small prefixes such as /31 and /32 in that particular rule type.
Frequently asked questions
Why can a range not always be one CIDR block?
A CIDR block is defined by a fixed prefix and free host bits, so its size is always a power of two and its first address always aligns to that size. A range with an arbitrary start or an arbitrary length satisfies neither condition, so it has to be assembled from several aligned pieces.
What does /32 mean in the output?
A single address. It appears at the ends of ranges that start or finish off a boundary, and it is completely normal in firewall and routing configuration where a rule applies to one host.
Is the block list the smallest possible?
Yes. The greedy approach used here is provably minimal for an exact cover: at each position, taking the largest legal block that fits cannot be improved on by taking a smaller one.
Put this on your own site
Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.
<iframe src="https://runthetests.com/embed/ip-range-to-cidr/" width="100%" height="560" style="border:1px solid #e5e5e5;border-radius:8px" title="IP Range to CIDR" loading="lazy"></iframe>
Preview it at https://runthetests.com/embed/ip-range-to-cidr/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.