Subnet Tools

IP Range to CIDR

Turn a range of IPv4 addresses into the exact list of CIDR blocks that covers it.

Worked example

A firewall rule must allow 10.0.0.5 to 10.0.0.20 and nothing else.

The range doesn't start on a block boundary, so it takes five blocks: 10.0.0.5/32, 10.0.0.6/31, 10.0.0.8/29, 10.0.0.16/30 and 10.0.0.20/32. Together they hold the 16 addresses exactly.

How it works

Starting from the first address, the tool takes the largest block that begins on a boundary at that address and doesn't run past the last address, then repeats from the next address until the range is covered. Everything runs in your browser; nothing is sent to a server.

Learn the theory

FAQ

Why does one range sometimes need several CIDR blocks?
A CIDR block always holds a power-of-two number of addresses and must start on a boundary that is a multiple of its size. A range such as 10.0.0.5 to 10.0.0.20 doesn't start or end on such a boundary, so it takes several smaller blocks (a /32, a /31, a /29, a /30 and another /32) to cover it exactly.
Can I just use one bigger block instead?
Only if it's acceptable to include extra addresses. 10.0.0.0/27 covers 10.0.0.5 to 10.0.0.20, but also 10.0.0.0 to 10.0.0.4 and 10.0.0.21 to 10.0.0.31. In a firewall rule or ACL that might allow traffic from hosts that shouldn't have it, which is why this tool gives the exact list.
Does it work for IPv6?
Not yet. This tool converts IPv4 ranges; the IPv6 Subnet Calculator covers IPv6 prefixes.

Related tools