How to use it
- Paste your ranges, one per line. Ranges, single addresses and CIDR blocks can be mixed.
- Leave Merge overlapping ranges on to get one clean, sorted list, or turn it off to keep each line separate.
- Copy the CIDR blocks into your firewall, security group or server config. The line under the result shows how many blocks and addresses there are.
How it works
Each address is treated as a number (32 bits for IPv4, 128 bits for IPv6). Starting at the first address of the range, the tool picks the largest block that:
- is aligned — the start address is divisible by the block size, which is what a /n prefix requires;
- fits — the block’s last address is not past the end of the range.
It writes that block, moves to the address after it and repeats until the range is covered. A block of 2^k addresses has the prefix length 32 − k for IPv4 (128 − k for IPv6).
Worked example
Range 10.0.0.1 – 10.0.0.254 (all of 10.0.0.0/24 except the network and broadcast addresses):
- 10.0.0.1 is odd, so only a single address fits: 10.0.0.1/32;
- 10.0.0.2 is divisible by 2: 10.0.0.2/31; then 10.0.0.4/30, 10.0.0.8/29, 10.0.0.16/28, 10.0.0.32/27 and 10.0.0.64/26;
- 10.0.0.128 could start a /25, but that would reach 10.0.0.255, past the end, so it gets 10.0.0.128/26; then 10.0.0.192/27, 10.0.0.224/28, 10.0.0.240/29, 10.0.0.248/30, 10.0.0.252/31 and 10.0.0.254/32.
That is 14 blocks for 254 addresses. The range 10.0.0.0 – 10.0.0.255 would be just one block, 10.0.0.0/24.
Tips
- Ranges that end in .0 and .255 convert best. A range that starts or ends in the middle of a block always needs extra small blocks.
- Check the address count. If the summary shows more addresses than you expected, two lines probably overlap or a typo widened a range.
- To see the network, mask and host range of a single block, use the IP subnet calculator.