Developer tools
IP range to CIDR converter
Turn a first and last IPv4 address into the smallest list of CIDR blocks.
A clear answer. Here’s how.
Starting at the first address, repeatedly takes the largest block that is aligned to its own size and still fits before the last address. The result is the minimal exact cover: the blocks add up to the range with no extra addresses. A range such as 192.168.0.0 to 192.168.1.255 becomes one /23, while an unaligned range needs several blocks.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- First address
- 10.0.0.5
- Last address
- 10.0.0.20
Example result
| CIDR block | First address | Last address | Addresses |
|---|---|---|---|
| 10.0.0.5/32 | 10.0.0.5 | 10.0.0.5 | 1 |
| 10.0.0.6/31 | 10.0.0.6 | 10.0.0.7 | 2 |
| 10.0.0.8/29 | 10.0.0.8 | 10.0.0.15 | 8 |
| 10.0.0.16/30 | 10.0.0.16 | 10.0.0.19 | 4 |
| 10.0.0.20/32 | 10.0.0.20 | 10.0.0.20 | 1 |
5 blocks cover 16 addresses exactly: the smallest CIDR list that spans the range with no extra addresses.