IP Range to CIDR
Convert an arbitrary start-to-end IPv4 range into the minimal set of CIDR blocks that covers it exactly - no more, no less.
Result
Exact decomposition
| Prefix | First | Last | Addresses |
|---|---|---|---|
| 192.168.1.5/32 | 192.168.1.5 | 192.168.1.5 | 1 |
| 192.168.1.6/31 | 192.168.1.6 | 192.168.1.7 | 2 |
| 192.168.1.8/29 | 192.168.1.8 | 192.168.1.15 | 8 |
| 192.168.1.16/28 | 192.168.1.16 | 192.168.1.31 | 16 |
| 192.168.1.32/27 | 192.168.1.32 | 192.168.1.63 | 32 |
| 192.168.1.64/26 | 192.168.1.64 | 192.168.1.127 | 64 |
| 192.168.1.128/25 | 192.168.1.128 | 192.168.1.255 | 128 |
| 192.168.2.0/25 | 192.168.2.0 | 192.168.2.127 | 128 |
| 192.168.2.128/26 | 192.168.2.128 | 192.168.2.191 | 64 |
| 192.168.2.192/29 | 192.168.2.192 | 192.168.2.199 | 8 |
| 192.168.2.200/32 | 192.168.2.200 | 192.168.2.200 | 1 |
192.168.1.5/32
192.168.1.6/31
192.168.1.8/29
192.168.1.16/28
192.168.1.32/27
192.168.1.64/26
192.168.1.128/25
192.168.2.0/25
192.168.2.128/26
192.168.2.192/29
192.168.2.200/32About IP Range to CIDR
Firewalls, DHCP servers and allocation spreadsheets like ranges. Routers, prefix lists and route filters want CIDR. This converts an arbitrary range into the exact set of prefixes that covers it - never one address more.
Designing ranges that stay small
Prefix count is a property of the boundaries, not the size. A range starting at .100 and ending at .199 needs half a dozen prefixes; shifting it to .128 through .255 makes it a single /25 of the same 128 addresses. When you control the allocation — DHCP pools, NAT pools, customer assignments — choose power-of-two boundaries and every downstream prefix list, route filter and firewall object stays short and reviewable.
Why the count varies so much
A range that starts and ends on power-of-two boundaries collapses into a single prefix. One that starts at .5 and ends at .200 needs a staircase of blocks: each step takes the largest prefix that both aligns with the current position and fits inside the remaining range. Ranges arranged by humans on decimal boundaries (100-199) are almost always the expensive kind.
Common use cases
- Converting a legacy firewall range object into prefix-list entries.
- Turning a DHCP scope into the CIDR notation a route filter needs.
- Checking how much prefix churn a proposed allocation boundary will cause.
Edge cases and gotchas
- The output covers the range exactly. If you want a single shorter summary that may over-cover, use the CIDR Aggregator with strict mode off.
- Ranges spanning classful boundaries are handled, but the block count grows quickly.