1. Home
  2. Developer tools
  3. IP Range to CIDR

IP Range to CIDR

Firewalls and cloud rules often take only CIDR blocks. Enter a start and end address and get the minimal list of blocks that matches the range with nothing extra.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use IP Range to CIDR

  1. Enter ranges as start - end, one per line.
  2. Read the list of CIDR blocks.
  3. Copy it into your firewall rule.

Features

  • Shortest exact list of blocks
  • IPv4 and IPv6
  • Many ranges at once
  • Shows how many addresses each range holds
  • Rejects reversed or mixed ranges
  • Copy or download

Supported formats

Input

  • First and last IPv4 address

You get

  • Minimal list of CIDR blocks

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the IP Range to CIDR is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • IPv4 only.
  • The result is the smallest list of blocks that covers the range exactly, which can be many blocks for an awkward range.

Guide

Converting an address range into the fewest CIDR blocks

Address ranges are how people describe things: “the supplier uses 203.0.113.10 to 203.0.113.200”. Firewalls, cloud security groups and route filters mostly want CIDR blocks instead. The page converts a range into the smallest set of blocks that covers it exactly, so nothing outside the range is allowed in by accident.

Why one range may need several blocks

A CIDR block is a start address and a prefix length. Two conditions apply: the number of addresses is a power of two, and the start is a multiple of that size. A /24 covers 256 addresses and must begin on a multiple of 256. A range such as 10.0.0.1 to 10.0.0.6 cannot be one block because it starts at an odd number and has six addresses. The only way to cover it exactly is with smaller aligned pieces.

The algorithm

The page starts at the first address. It picks the largest block whose size divides the start address and that does not run past the end of the range, adds it to the list, moves the start to just after that block and repeats. This greedy approach is provably minimal for ranges, because at each step any smaller block could only be replaced by a larger one that is aligned. It works the same way for IPv6 with 128-bit addresses. The output lists one block per line in order, and the summary shows the total addresses and the block count.

Using it

Enter ranges as start - end, one per line. You can paste several at once and each gets its own result group; a range that mixes IPv4 and IPv6, or lacks an end, gets an error message instead. Copy or download the list of blocks to use in a rule set. The sample includes an exact /22, a range that needs four blocks, a messy range that needs eight, and an IPv6 range, so you can see how alignment affects the count.

A worked example

Take 203.0.113.10 - 203.0.113.200, which is 191 addresses. Starting at .10, the largest aligned block is a /31 (.10 to .11) because 10 is not a multiple of 4. Next is .12 as a /30 (to .15), then .16 as a /28 (to .31), then .32 as a /27 (to .63), then .64 as a /26 (to .127). At .128 a /26 fits again (to .191), but a /25 would run past .200. Next is .192 as a /29 (to .199) and finally .200 as a /32. That is eight blocks, matching the page. By contrast 192.168.0.0 - 192.168.3.255 is exactly one /22 with 1,024 addresses, and 2001:db8:: - 2001:db8::ffff is a single IPv6 /112.

Limits

The result is exact, so it can be long for awkward ranges, and some platforms limit the number of rules. In that case you must decide whether to widen the range, which this page does not do on its own. If you want to see how widening would work, the Route Summarization Calculator shows the cost of a looser covering block. The page does not check overlaps between lines or whether the addresses are public.

Checked against the current version of the IP Range to CIDR on .

Frequently asked questions

Why can't an arbitrary range be written as one CIDR block?

A block must start on a multiple of its own size and contain a power-of-two number of addresses. A range that begins at 10 or has 191 addresses breaks one of those rules, so it takes several blocks.

Is it better to use fewer, larger blocks that cover extra addresses?

Only if allowing the extra addresses is acceptable. For firewall rules and allow lists it usually is not, which is why the page returns an exact cover, and a looser summary is a separate decision.

Why does 10.0.0.1 - 10.0.0.6 need four blocks?

A block must start on a multiple of its size. The range splits into 10.0.0.1/32, 10.0.0.2/31, 10.0.0.4/31 and 10.0.0.6/32.

Can a range be covered by a single larger block?

Only if it starts on a boundary and its length is a power of two. Otherwise a larger block would include addresses outside the range.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.