IP range to CIDR converter
Get the fewest CIDR blocks that cover an IPv4 range exactly, ready for a firewall rule or allow-list.
Why a range turns into several blocks
A CIDR block has to start on a boundary that matches its size, so most ranges cannot be written as one block. Firewalls, cloud security groups, routers and blocklists speak CIDR. Registries, spreadsheets and threat feeds often publish ranges like 10.0.0.5 - 10.0.0.20. To bridge the two, the range is split into aligned pieces, and this page finds the fewest pieces that cover it exactly.
| Block | Addresses | Covers |
|---|---|---|
10.0.0.5/32 | 1 | 10.0.0.5 |
10.0.0.6/31 | 2 | 10.0.0.6 to 10.0.0.7 |
10.0.0.8/29 | 8 | 10.0.0.8 to 10.0.0.15 |
10.0.0.16/30 | 4 | 10.0.0.16 to 10.0.0.19 |
10.0.0.20/32 | 1 | 10.0.0.20 |
That table is the answer for 10.0.0.5 - 10.0.0.20: five blocks and 16 addresses, with no overlap and no extras.
How to use it
- Enter a rangeWrite
10.0.0.5 - 10.0.0.20,10.0.0.5 to 10.0.0.20or the short form10.0.0.5-20. Put one range on each line, up to 1,000 lines. - Read the listEach range comes back as its blocks in order. For a single range, you also see the first address, last address and size of every block, so you can check that nothing is missing.
- Decide whether one covering block will doWhen a range needs several blocks, the page also shows the smallest single block that holds it, and how many extra addresses that block would let in. Use it only if a few extra addresses are fine.
Exact list or covering block?
Use the exact list for allow-lists and for anything where letting in an extra address would be a security problem. A covering block is shorter to write, but it is broader. For 10.0.0.5 - 10.0.0.20, the smallest single block that holds the range is 10.0.0.0/27. It has 32 addresses, 16 more than you asked for.
- The worst case. An IPv4 range needs at most 62 blocks. Most real ranges need far fewer.
- Aligned ranges collapse.
10.0.0.0 - 10.0.0.255becomes the single block10.0.0.0/24. - Ranges that cross a boundary.
10.0.0.200 - 10.0.1.50can't be one/23, because10.0.0.0/23would let in 405 addresses outside the range.
Common problems
- The start is after the end. Swap them. The page reports the order problem instead of guessing.
- A CIDR block instead of a range. A line like
10.0.0.0/24is reported, with a pointer to the CIDR to IP range converter. - IPv6 or mixed addresses. A range can't mix IPv4 and IPv6, and IPv6 ranges have their own page: IPv6 range to CIDR.
- Too many blocks for a rule limit. Cloud providers cap the rules in a group. Use the covering block if the extra addresses are acceptable, or merge neighbouring ranges before you convert.
- Registry ranges with odd ends. Old assignments (for example
inetnumentries in registry data) are often not aligned to CIDR boundaries, which is why a short list of blocks appears. - Gaps and overlaps between ranges. Ranges are not merged here. Convert each one, then combine the blocks afterwards.
How the fewest blocks are found
Starting at the first address, the page picks the largest block that begins exactly there and does not run past the end. It writes that block down, moves to the address after it and repeats until it reaches the end. That gives the smallest valid list, and it never needs more than 62 blocks. It uses whole-number arithmetic only, so nothing is rounded.
# The same maths in Python, for checking
python3 -c "import ipaddress as i; print(list(i.summarize_address_range(i.ip_address('10.0.0.5'), i.ip_address('10.0.0.20'))))"To go from blocks to boundaries instead, use the CIDR to IP range converter. The standard behind it is RFC 4632 (CIDR), which replaced RFC 1519.
Questions people ask
How do I convert an IP range to CIDR notation?
Give the start and end address, and take the list of blocks that comes back. The list is the smallest set of CIDR blocks whose union is exactly your range, with no overlap and no extra addresses. For 10.0.0.5 - 10.0.0.20, that is five blocks. If the range happens to line up with one block, you get a single CIDR.
Why isn't my range a single CIDR block?
A block has to start at an address that divides evenly by its size. A /24 must start on a multiple of 256, and a /29 on a multiple of 8. When your range starts or ends off those boundaries, it has to be split into aligned pieces. That is normal, and common for old registry assignments.
What is a covering block?
It is the smallest single CIDR block that contains your whole range. It is shorter to write, but it usually includes addresses outside your range, and the page tells you how many. For 10.0.0.5 - 10.0.0.20, the covering block 10.0.0.0/27 lets in 16 extra addresses.
Is the output safe for a firewall allow-list?
The exact list is. It admits only the addresses in your range and nothing more. Avoid the covering block in security rules unless you are happy to admit the extra addresses. If your firewall limits the number of entries, merge neighbouring ranges first, or check the covering block carefully before you use it.
What does 10.0.0.5-20 mean?
It is a short form of 10.0.0.5 - 10.0.0.20. The number after the dash replaces the last number of the start address. The page tells you how it read the end, so you can check it. This shortcut works for IPv4 only. For IPv6, write both addresses in full.
How many blocks can a range need at most?
An IPv4 range never needs more than 62 blocks, and most need far fewer. The worst case starts one address after a big boundary and ends one address before another, such as 0.0.0.1 - 255.255.255.254. Real-world ranges usually need only a handful of blocks.
Can I convert IPv6 ranges?
Yes. Use IPv6 range to CIDR, which does the same job with 128-bit addresses. An IPv6 range can need up to 254 prefixes. Both ends of a range must be the same family, so don't mix IPv4 and IPv6 addresses on one line.
Use it from AI, the API or the command line
Every LookupOwl tool is also a free API and an MCP tool, with no key and no account. This one is ip_range_convert. Please be kind to the rate limits.
curl "https://lookupowl.com/api/v1/tools/ip-range-convert?q=10.0.0.5+-+10.0.0.20"claude mcp add --transport http lookupowl https://lookupowl.com/mcp