1001Ferramentas
📏 Security

Convert IP Range to CIDR List

Convert an IP range (start and end) into the smallest list of equivalent CIDR blocks. An essential tool for configuring firewalls, ACLs and network rules.

Turning an IP range into CIDR blocks

A vendor tells you to allow 10.0.0.1 through 10.0.5.255. Your firewall field, your bucket policy and your security group all want CIDR notation. Doing that translation by hand is tedious and easy to get wrong, and a wrong block either opens addresses you never meant to open or leaves out the exact IP your customer calls the API from.

The algorithm is greedy and walks from the start toward the end. At each step it picks the largest aligned block that begins at the current address without running past the finish, writes that CIDR down and moves on. Alignment drives the length of the list: 10.0.0.1 to 10.0.5.255 produces eleven blocks, starting with a lonely /32. Shift the start to 10.0.0.0 and the same span collapses to two, 10.0.0.0/22 and 10.0.4.0/23.

If the list comes back too long for your rule field, try aligning the edges to powers of two, since one spare address at the boundary often halves the output. The result is exact and never includes an IP outside the range you gave, unlike the old habit of rounding everything up to a /24. A start above the end returns an error, and only IPv4 is accepted. Everything is computed in your browser.

Frequently asked questions

Why did a small range turn into eleven blocks?
Because the first address is not aligned. A CIDR block always starts on a multiple of its own size, so 10.0.0.1 can only begin a /32.
Does the list match the range exactly?
Yes. Not one address more, not one less than the interval you typed. That precision is why the list sometimes gets long.
Does it work with IPv6?
No. This is IPv4 only, from 0.0.0.0 to 255.255.255.255. That full span, incidentally, comes back as the single block 0.0.0.0/0.

Related Tools