Skip to content
gl.tools

Convert an IP range to CIDR

Firewalls, access lists and routes want CIDR blocks; people think in “from 10.0.0.5 to 10.0.0.37”. This tool converts both ways – and merges several blocks into the smallest possible list. IPv4 and IPv6, calculated in your browser.

  • Free
  • No sign-up
  • Runs in your browser
  • Nothing is transmitted
What do you have?

You know the first and last address and need the blocks for a firewall rule or access list.

From10.0.0.5
To10.0.0.37
Addresses33
Blocks needed6
10.0.0.5/32
10.0.0.6/31
10.0.0.8/29
10.0.0.16/28
10.0.0.32/30
10.0.0.36/31

The calculation runs in your browser. The addresses are not sent anywhere and not looked up anywhere.

Did this help you? Buy me a coffee

Common questions

Why does one range turn into several blocks?
Because a CIDR block cannot start just anywhere. Its size is always a power of two and it begins at a multiple of its own size – a /24 therefore only at an address ending in 0. A range that starts in the middle of a network and ends in the middle of one cannot be covered by a single block. From 10.0.0.5 to 10.0.0.37 becomes six blocks: first the single .5, then a pair, then ever bigger pieces, until small ones are left at the end. Fewer than those six is not possible.
Does the result cover exactly the range?
Yes, and this is where the tool has to be careful: one address too many is an open door in a firewall rule, one too few is a call from a colleague. The blocks are gapless, do not overlap, and together hold exactly the number of addresses in the range – not one more. That is not checked against examples but against four hundred random ranges on every test run.
What does merging do?
It squeezes a grown list down to the smallest one. Access lists get extended over years, and then the same network is in there three times, plus two halves that make a whole: 10.0.0.0/25 and 10.0.0.128/25 are 10.0.0.0/24. Enter the blocks one per line and you get the short version – overlapping ones merged, contained ones swallowed, adjacent ones joined.
How do I get from a CIDR block back to from–to?
Through the same direction as merging: enter the block one per line, and next to each one you get the first and the last address with the count – even if it is a single block. If you also need the network address, the broadcast address and the wildcard mask, the subnet calculator is the tool for that; it shows the whole calculation for exactly one network.
What happens to 10.0.0.37/24?
It is read as 10.0.0.0/24, and the tool says so. Strictly speaking the notation is wrong, because .37 is not the start of the block – but every firewall interface in the world reads it that way, and whoever types it means exactly that. Swallowing it silently would be as wrong as rejecting it; that is why the reinterpretation is shown.
I only have one address, not a range – what is its CIDR?
A single IPv4 address is a /32, a single IPv6 address a /128: the prefix then covers every bit, and exactly one address is left. That is what firewalls want when a rule applies to one machine only. Enter the same address in both fields and you get it.
Does IPv6 work too?
Yes, on equal terms. Everything is calculated with arbitrarily large integers, because the number of addresses in a single /64 already exceeds ordinary numbers – 18,446,744,073,709,551,616 of them. At such sizes the power of two is shown as well: “2^64” says more than twenty digits. IPv4 and IPv6 cannot be joined into one range, though; that would not be arithmetic, it would be a typo.
Are the addresses looked up anywhere?
No. This calculates, it does not ask – no DNS, no geolocation, no request to any third-party service. The addresses never leave your browser. That is not only a principle here: internal address ranges say something about a company's network, and that does not belong in someone else's server log.

Related tools

All tools of this kind: Network tools