How to Convert an IP Range to CIDR
Converting an IP range to CIDR means turning a start and end address into one or more CIDR blocks that cover exactly the same addresses.
Example:
192.168.1.0 - 192.168.1.255
becomes:
192.168.1.0/24
That example aligns perfectly to a /24, so it only needs one CIDR block.
For an uneven range, use the IP Range to CIDR Calculator.
Why Some IP Ranges Need Multiple CIDR Blocks
CIDR blocks must start on valid binary boundaries.
That means not every start/end range can be represented by one CIDR block without including extra addresses.
Example:
192.168.1.10 - 192.168.1.20
Minimal CIDR output:
192.168.1.10/31
192.168.1.12/30
192.168.1.16/30
192.168.1.20/32
This looks less tidy than a single block, but it is more accurate. It covers the requested range without allowing unrelated IP addresses.
When This Conversion Matters
IP range to CIDR conversion is common when working with:
- Firewall allowlists
- ACLs
- Route tables
- Cloud security rules
- Vendor IP range exports
- Migration spreadsheets
Many systems expect CIDR notation even when humans describe the address space as a start and end range.
Manual Conversion Workflow
At a high level, the process is:
- Convert the start IP and end IP to integer values.
- Find the largest CIDR block aligned at the start address.
- Make sure that block does not extend past the end address.
- Add the block to the result.
- Move the start address forward and repeat.
The calculator handles that loop automatically and returns the minimal block list.
Common Mistakes
- Expanding the range too far to force a single CIDR block
- Forgetting that exact coverage may require several CIDRs
- Reversing the start and end address
- Mixing IPv4 ranges with IPv6 notation
- Copying ranges from spreadsheets with hidden formatting issues
For the reverse direction, use the CIDR to IP Range Calculator.