IP Range to CIDR Converter

Enter the first and last address of a range. You get the shortest list of CIDR blocks that covers every address in the range and nothing outside it, for IPv4 or IPv6.

Worked examples

A range that does not line up

192.168.1.5 to 192.168.1.20

192.168.1.5/32 192.168.1.6/31 192.168.1.8/29 192.168.1.16/30 192.168.1.20/32

Together they cover the 16 addresses from .5 to .20.

A whole network

10.0.0.0 to 10.0.0.255

10.0.0.0/24

The range starts on a boundary and holds exactly 256 addresses.

About IP Range to CIDR Converter

Firewall rules, cloud security groups, allow lists and routing tables are written in CIDR notation, a network address followed by a prefix length. Address ranges, on the other hand, often arrive as a start and an end, from a provider's documentation, a spreadsheet or a scan. Unless the range happens to fit a power of two exactly, it cannot be written as one block.

This converter takes the first and last address and splits the range into the fewest CIDR blocks that cover every address inside it and nothing outside it. It works by taking, at each step, the biggest block that starts at the current address, is aligned correctly and still fits in what is left. The page also shows how many addresses the blocks cover in total, so you can check the answer against the size you expected. IPv4 and IPv6 both work.

How to use IP Range to CIDR Converter

  1. Enter the first address of the range.
  2. Enter the last address of the range. Both must be IPv4 or both IPv6.
  3. Read the list of blocks, one per line.
  4. Check the address count, then copy the blocks into your rule or list.

Common uses

  • Adding a provider's address range to a firewall
  • Turning a spreadsheet of start and end addresses into allow list entries
  • Checking that a range lines up with network boundaries
  • Splitting an IPv6 range into prefixes

Frequently asked questions

Why does a range need several blocks?

A CIDR block always covers a power of two addresses starting on a matching boundary. A range that starts or ends away from such boundaries needs more than one block.

Is the list the shortest possible?

Yes. Taking the largest aligned block at each step gives the minimum number of blocks for an exact cover.

What if I want one larger block that includes extra addresses?

This tool covers the range exactly. If you can accept extra addresses, use the CIDR subnet calculator to find the smallest single block that contains both ends.

Does it accept numbers or hex?

For IPv4 you can type dotted decimal, a whole number, 0x hex or binary. For IPv6 use the usual colon forms.

How is the address count worked out?

It is the last address minus the first, plus one, shown with thousands separators. IPv6 ranges give very large numbers.