Tools / Subnet calculators
IP Range to CIDR
Convert a start and end address into the shortest exact list of CIDR blocks.
When you need this
Allocation records, abuse reports and provider documentation often give address space as a plain range, while firewalls, cloud security groups, route filters and access lists expect CIDR blocks. This tool does the conversion without rounding the range up to a larger block, which would silently include addresses you did not mean to allow or block.
How the conversion works
Starting at the first address, the tool takes the largest block that both begins exactly there and ends at or before the last address, then repeats from the next free address. For 192.168.1.10 to 192.168.1.50 that gives a /31, a /30, two /28 blocks, a /31 and a /32.
IPv4 and IPv6 are both supported, but the two ends must be the same version.
Questions and answers
Why does my range need several CIDR blocks?
A single CIDR block must start on a boundary that matches its size and contain a power-of-two number of addresses. A range such as 192.168.1.10 to 192.168.1.50 fits neither rule, so it is covered by several smaller blocks placed side by side.
Is the result exact?
Yes. The blocks cover every address from start to end and nothing outside the range, using the fewest blocks possible.
What is the largest number of blocks a range can need?
At most 62 for IPv4 and 254 for IPv6, however large the range is.