🎯 IP Range Calculator
Calculate statistics for IP address ranges including total addresses, usable hosts, and network information.
Counting the range, then carving it into CIDR blocks
Both addresses are flattened to 32-bit integers first. The count is inclusive, so both ends are part of the answer:
value = (o1 << 24) | (o2 << 16) | (o3 << 8) | o4
range size = end value - start value + 1
The block list is built greedily. Starting at the first address, the tool takes the biggest prefix whose block is aligned to its own size and does not run past the end, moves to the address after it, and repeats.
Run 192.168.1.10 to 192.168.1.20: 11 addresses, four blocks - .10/31, .12/30, .16/30 and .20/32. The first is a /31 because .10 is even but not a multiple of 4; .16 cannot take the /28 or /29 it is aligned for without overshooting .20. The sizes 2 + 4 + 4 + 1 come back to 11.
Reading the block list
- Ragged ends cost blocks. A range on clean boundaries, .0 to .255, is one /24. Move either end by a single address and the list grows.
- Alignment, not size, decides. A block can only start on a multiple of its own length, which is why .12 cannot begin a /29.
- The largest block emitted is a /8; wider ranges come back as a series of /8s rather than one short prefix.
Frequently asked questions
How many IP addresses are between two addresses?
Subtract the start from the end and add one, because both ends count. 10.0.0.5 to 10.0.0.9 is five addresses, not four.
How do I turn an IP range into CIDR notation?
Split it into aligned power-of-two blocks. Any range can be covered exactly, but only one starting on a boundary with a power-of-two length is a single prefix.
Why does one small range produce several CIDR blocks?
Because a prefix cannot begin partway through a block. Covering 192.168.1.10 to 192.168.1.20 takes a /31, two /30s and a /32 - eleven addresses that no single prefix can express.