Inclusive range · IPv4 · IPv6

IP Range to CIDR Converter

Enter the first and last address of a range. You get the smallest list of CIDR blocks that covers exactly those addresses, ready to paste into a router, firewall or allowlist.

Range

Both endpoints are included. You can also paste first - last into the first field.

Try

How the conversion works

  1. Start at the first address. Find the largest block that starts exactly there and whose last address stays at or below the end of the range.
  2. Take that block, then move to the address just after it.
  3. Repeat until the whole range is covered. The result is exact: no address outside the range is included.

For 192.168.1.10 to 192.168.1.20, the first address is even but not divisible by 4, so the largest aligned block is a /31. After that the alignment improves: a /30 at .12, another /30 at .16, and a final /32 at .20. That is 4 blocks for 11 addresses.

Edge cases worth checking

To inspect one of the resulting blocks, open it in the subnet calculator, or summarize a longer list on the CIDR tools page. To check whether two ranges clash, use the overlap checker.

Questions

How do I convert an IP range to CIDR blocks?

Start at the first address and take the largest CIDR block that starts there and does not pass the last address. Then move to the next address and repeat. 192.168.1.10 to 192.168.1.20 becomes 192.168.1.10/31, 192.168.1.12/30, 192.168.1.16/30 and 192.168.1.20/32.

Why does a range produce more than one CIDR block?

A CIDR block must start on a multiple of its own size, so a range that starts or ends off an alignment boundary cannot be one block. The converter splits it into the smallest set of aligned blocks that cover exactly the same addresses.

Is the last address included?

Yes. The first and last addresses are both part of the range, so 192.168.1.10 to 192.168.1.20 covers 11 addresses and ends with the 192.168.1.20/32 block.

Does it work with IPv6 ranges?

Yes. Enter IPv6 endpoints such as 2001:db8::10 to 2001:db8::20 and the same algorithm returns IPv6 CIDR blocks. Both endpoints must be the same IP version.