ZapKit

IP range to CIDR

Firewalls, cloud security groups and allow lists want CIDR notation; this turns any address range into exactly the right blocks, and back.

What is an IP range to CIDR converter?

An IP range to CIDR converter expresses a span of IPv4 addresses, from a start address to an end address, as the smallest set of CIDR blocks that covers it exactly. Many systems only accept CIDR notation, including firewalls, AWS and Azure security rules, nginx and web application firewalls.

Enter one range per line and get its blocks, with the number of addresses and blocks needed. Enter a CIDR block instead and it's expanded the other way, to its first and last address and size. Mixed lists are fine, and the result can be copied or downloaded as text.

How to use the IP range to CIDR

  1. 1.Enter ranges or blocks

    One per line: 10.0.0.5 - 10.0.0.20, or 172.16.0.0/22.

  2. 2.Read the result

    Each range becomes CIDR blocks; each block becomes a range.

  3. 3.Copy or download

    Paste the list into your firewall or config.

Example: an odd-sized range

Allowing 10.0.0.5 to 10.0.0.20 (16 addresses) through a firewall:

Blocks
10.0.0.5/32, 10.0.0.6/31, 10.0.0.8/29, 10.0.0.16/30, 10.0.0.20/32
Check
1 + 2 + 8 + 4 + 1 = 16 addresses
Reverse
172.16.0.0/22 → 172.16.0.0 – 172.16.3.255

Five rules cover the range exactly, with no address left out or let in by mistake.

Why one range can need several blocks

A CIDR block must start on a boundary that matches its size: a /29 always begins at a multiple of 8. A range that starts or ends between boundaries is covered by a sequence of blocks, largest possible first, with no gaps and no extra addresses.

That's why 10.0.0.5 to 10.0.0.20 takes five blocks, while 192.168.1.0 to 192.168.1.255 is exactly one /24. Lines starting with # are treated as comments and ignored.

Frequently asked questions

Will the blocks include addresses outside my range?

No. They cover the range exactly.

Can I paste many ranges at once?

Yes, one per line. Each gets its own heading in the result.

Which separators work between start and end?

A hyphen, en dash, the word to, a comma or a space.

Does it handle IPv6?

Not yet; it's for IPv4 ranges.

More Developer tools