IP Range ⇄ CIDR
An IP range to the minimal CIDR blocks, and CIDR back to a range.
About this tool
Free IP range to CIDR converter. Turn an arbitrary start–end IP range into the smallest set of CIDR blocks that cover it exactly, and convert any CIDR back to its first/last address and size — built for firewall rules, ACLs and cloud security groups. Everything runs entirely in your browser — nothing you type is sent to a server.
Firewall rules, cloud security groups and many ACLs accept CIDR blocks but not arbitrary ranges. Turning a start and end address into CIDR by hand is error-prone. This converter returns the smallest set of blocks that covers the range exactly, and converts a CIDR block back to its first and last address.
How to use the IP Range ⇄ CIDR
- Enter a start and end IP, for example
192.168.1.10to192.168.1.20. - Run the conversion and read the list of CIDR blocks.
- Or enter a CIDR block to see its first and last address and size.
- Paste the blocks into your firewall object group or security group.
Example: 192.168.1.10 to 192.168.1.20
192.168.1.10/31 (.10 - .11) 192.168.1.12/30 (.12 - .15) 192.168.1.16/30 (.16 - .19) 192.168.1.20/32 (.20)
Eleven addresses need four blocks because each block must start on a multiple of its own size. Ranges that start and end on boundaries, such as .0 to .63, collapse into one block.
How the conversion works
The algorithm starts at the first address and repeatedly takes the largest CIDR block that both starts at the current address and does not go past the end of the range. A block of size 2^n can only start at an address divisible by 2^n, so an odd starting address can only begin a /32 and an address ending in .12 can begin at most a /30.
After placing each block, it moves to the next address and repeats. The result is the smallest possible list of blocks; no other combination covers the range exactly with fewer entries.
Going the other way is simple arithmetic: a /n block contains 2^(32-n) addresses, from the network address to the network address plus that size minus one.
Reading the results
- CIDR blocks
- Exact cover of the range with no extra addresses.
- Block count
- A high count suggests the range was chosen without regard to boundaries; aligning it would simplify rules.
Common mistakes
- Rounding a range to one larger block and so allowing addresses you did not intend.
- Mixing up the end address, especially across a /24 boundary.
Frequently asked questions
Why does a small range need several CIDR blocks?
Each CIDR block must start at a multiple of its size; ranges that do not align must be covered by several blocks.
Can firewalls use ranges directly?
Many, including FortiGate and Palo Alto, support range objects. Cloud security groups and many ACLs require CIDR.