IP Range β†’ CIDR Converter

Convert an IP range to minimal CIDR blocks

The IP Range to CIDR Converter transforms any start-end IP address range into the minimal set of CIDR blocks that cover exactly that range. Enter a start address like 192.168.1.0 and an end address like 192.168.1.255 to get a single 192.168.1.0/24, or enter 192.168.1.5 to 192.168.1.20 to see the five CIDR blocks needed to cover that non-aligned range precisely.

Understanding IP Ranges and CIDR Notation

If you have worked with firewalls, threat intelligence feeds, or legacy network documentation, you have almost certainly encountered IP addresses specified as start-end ranges. A vendor might tell you their service runs from 203.0.113.0 to 203.0.113.127, or a geolocation database might list country allocations as pairs of addresses. The problem is that most modern network infrastructure -- routers, cloud security groups, infrastructure-as-code templates -- expects addresses in CIDR notation, not ranges.

CIDR (Classless Inter-Domain Routing) notation represents a block of addresses using a network address and a prefix length, like 192.168.1.0/24. The prefix length dictates how many leading bits are fixed, and the remaining bits define the host space. A CIDR block must always start at an address that is evenly divisible by its size, which is a power of two. A /24 (256 addresses) must start at an address ending in .0, a /25 (128 addresses) must start at .0 or .128, and so on. This binary alignment rule is why an arbitrary range like .5 to .20 cannot be expressed as a single CIDR block -- you need multiple blocks of different sizes to tile the range exactly without including any extra addresses.

This converter does that tiling for you. It takes any start-end range and computes the mathematically minimal set of CIDR blocks that cover every address in the range and nothing more. Whether you are migrating legacy firewall rules, importing threat feeds, or converting DHCP scope documentation, the output is ready to paste directly into your configurations.

How to Convert an IP Range to CIDR Notation

  1. Enter the start IP address of your range (e.g., 192.168.1.0)
  2. Enter the end IP address of your range (e.g., 192.168.1.255)
  3. The tool calculates the minimal set of CIDR blocks that precisely covers the range
  4. Copy the resulting CIDR list for use in firewalls, routing tables, or infrastructure-as-code templates

IP Range to CIDR Conversion Examples

Start IPEnd IPCIDR OutputAddresses
192.168.1.0192.168.1.255192.168.1.0/24256
10.0.0.010.0.0.12710.0.0.0/25128
172.16.0.0172.16.1.255172.16.0.0/23512
192.168.1.5192.168.1.20192.168.1.5/32, 192.168.1.6/31, 192.168.1.8/29, 192.168.1.16/30, 192.168.1.20/3216
10.0.0.010.0.0.310.0.0.0/304

Ranges that align to power-of-two boundaries (like .0 to .255) convert to a single CIDR block. Non-aligned ranges like 192.168.1.5 to 192.168.1.20 require multiple CIDR blocks to represent exactly.

When to Use the IP Range to CIDR Converter

  • Firewall migration -- converting legacy start-end range rules to CIDR notation for modern platforms like AWS Security Groups or Azure NSGs
  • Threat intelligence feeds -- geolocation and reputation databases often provide IP ranges that need CIDR conversion for import into blocklists
  • Route configuration -- routers and BGP configurations require CIDR notation, not start-end ranges
  • Infrastructure-as-code -- Terraform, CloudFormation, and Ansible modules expect CIDR blocks for network definitions
  • DHCP scope documentation -- translating DHCP scope ranges into equivalent CIDR blocks for network documentation
  • Network scanning -- converting vendor-provided IP ranges into CIDR for use with tools like Nmap or Masscan

How IP Range to CIDR Conversion Works

The conversion algorithm works by finding the largest possible CIDR block starting at the current position that fits within the remaining range, then advancing and repeating.

The Algorithm Step by Step

  1. Start at the first IP in the range
  2. Find the longest prefix (largest block) that starts at this address and does not exceed the end address
  3. Record that CIDR block and advance to the address after the block ends
  4. Repeat until the entire range is covered

The key constraint is that a CIDR block of prefix length /n must start at an address divisible by 2^(32-n). For example, a /24 block must start at an address where the last octet is 0. This alignment requirement is why non-aligned ranges produce multiple CIDR blocks.

Binary Alignment Example

For the range 192.168.1.5 to 192.168.1.20:

Step 1: Start at .5 (odd) -> largest aligned block is /32
        192.168.1.5/32    covers .5

Step 2: Start at .6 (divisible by 2, not 4) -> /31
        192.168.1.6/31    covers .6-.7

Step 3: Start at .8 (divisible by 8) -> /29
        192.168.1.8/29    covers .8-.15

Step 4: Start at .16 (divisible by 4, but /30 would go to .19) -> /30
        192.168.1.16/30   covers .16-.19

Step 5: Start at .20 -> /32
        192.168.1.20/32   covers .20

IPv6 Range Conversion

The same algorithm applies to IPv6 ranges but with 128-bit addresses instead of 32-bit. A range like 2001:db8::1 to 2001:db8::ff follows the same binary alignment rules, producing the minimal set of IPv6 CIDR blocks.

Practical Tips for Range-to-CIDR Conversion

The most common reason to convert ranges to CIDR is firewall migration. When you are moving from a legacy platform that uses start-end notation to a modern platform that uses CIDR, you will quickly discover that some of your old rules produce surprisingly long CIDR lists. A rule covering .1 to .254 (the old-style "all usable hosts" range) converts to multiple CIDR blocks rather than a clean /24 because the range excludes the network and broadcast addresses. In practice, it is usually better to rewrite the rule as the full /24 rather than carry over a list of six or seven CIDR blocks, unless you genuinely need to exclude the network and broadcast addresses from the rule.

Another common pitfall is assuming that fewer CIDR blocks is always better. The output of this converter is already the mathematical minimum -- you cannot reduce it further without either including extra addresses or leaving some addresses uncovered. If the output seems excessive, ask whether your original range is actually correct. Often, ranges come from legacy systems where someone typed .1 to .254 when they really meant the entire /24. Cleaning up the intent at the source is better than fighting with the CIDR math downstream.

When processing threat intelligence feeds in bulk, you may end up with thousands of CIDR blocks from converting thousands of ranges. Consider piping the output through a CIDR Aggregator to combine adjacent blocks. Two consecutive ranges that convert independently might produce blocks that can be merged, reducing your total rule count further.

Frequently Asked Questions

Why does my IP range produce multiple CIDR blocks instead of one?

CIDR blocks must align to binary boundaries. A /24 must start at a .0 address, a /23 at an even-numbered third octet, and so on. If your range starts or ends at a non-aligned address, the tool must use multiple smaller CIDR blocks to cover it exactly without including extra addresses.

Can I combine the output CIDR blocks into fewer blocks?

No -- the output is already the mathematically minimal set. Every block is necessary to cover the exact range specified. Removing any block would leave addresses uncovered, and combining blocks would include addresses outside your range.

What is the maximum number of CIDR blocks a single range can produce?

For IPv4, a range can produce at most 62 CIDR blocks (31 for the ascending portion and 31 for the descending). In practice, most real-world ranges produce fewer than 10 blocks.

Does this tool handle IPv6 ranges?

Yes. The same algorithm applies to 128-bit IPv6 addresses. Enter IPv6 start and end addresses and the tool will produce the minimal set of IPv6 CIDR blocks following identical binary alignment rules.

What if my start address is greater than my end address?

The tool will return an error. The start IP must be numerically less than or equal to the end IP. If you have the addresses reversed, swap them before converting.

Related Tools

IPparseβ€’Free Network & Subnet Calculator Tools

Β© 2026 IPparse. All tools run locally in your browser.

100% Privacy-First β€’ No Data Collected