IPv4 range expander

Given a start and an end IPv4 address, this tool calculates a valid IPv4 subnet along with its CIDR notation.

loading IPv4 range expander
About this tool

What is an IP range to CIDR converter?

Routers, firewalls, cloud security groups and allow-lists do not understand "from 192.168.1.10 to 192.168.1.200". They want CIDR blocks such as 192.168.1.0/24. An IPv4 range expander (or IP range to CIDR converter) takes a start address and an end address and writes the range as CIDR notation, the way RFC 4632 defines it.

A range rarely lines up with a single block. Only ranges that start on a power-of-two boundary and have a power-of-two size are exactly one CIDR block. For everything else there are two honest answers, and this tool gives both:

  • the smallest single block that contains the whole range, which may include addresses outside it (the "rounded to the block" result), and
  • the exact list of blocks, the minimum number of CIDR blocks that cover the range and nothing else.

Use the first when you can afford to allow a bit more and want one short line, and the second when the rule must not match anything beyond the range, for example in a firewall deny rule or an AWS security group. The calculation runs in your browser and nothing you type is sent to a server.

How to convert an IP range to CIDR

  1. Type the first address of the range in the start field and the last address in the end field. Both must be valid IPv4 addresses with four numbers from 0 to 255.
  2. Read the first table: start and end address, how many addresses you entered, and for the enclosing block its network address, last address, size and CIDR.
  3. Compare "Entered" and "Rounded to the block" to see how many extra addresses the single block would include.
  4. Below it, read the exact CIDR blocks. Use the copy button to copy them all, one per line, for your configuration file.
  5. If you typed them in the wrong order, the tool explains that the end is lower than the start; the swap button flips the two fields.

Examples

A range that is exactly one block

10.0.0.0 to 10.0.3.255 is 1,024 addresses on a boundary of 1,024, so the result is a single block:

10.0.0.0/22

A range that is not aligned

192.168.1.10 to 192.168.1.200 has 191 addresses. The smallest single block that contains it is 192.168.1.0/24 (256 addresses, 65 extra). The exact list needs eight blocks:

192.168.1.10/31
192.168.1.12/30
192.168.1.16/28
192.168.1.32/27
192.168.1.64/26
192.168.1.128/26
192.168.1.192/29
192.168.1.200/32

A short range

10.0.0.5 to 10.0.0.20 has 16 addresses. One block would be 10.0.0.0/27 (32 addresses), while the exact answer is five 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

A single address

Start and end equal to 203.0.113.7 give 203.0.113.7/32.

Common mistakes

  • Using the enclosing block where the rule must be exact. In a deny rule the single block can block addresses you meant to allow. Use the exact list.
  • Swapping start and end. An end lower than the start has no result. Use the swap button.
  • Including the network and broadcast address by habit. In a range you define the endpoints yourself; the tool treats every address between them as part of the range.
  • Entering a hostname or a CIDR in a field. Each field takes one IPv4 address only; for a CIDR use the subnet calculator.
  • Expecting IPv6 support. This tool is IPv4 only.

Frequently asked questions

How do I convert an IP range to CIDR?

Find the largest block that starts at the first address and fits inside the range, add it, move to the next address and repeat. The tool does this and lists the blocks.

Why does one range give several CIDR blocks?

Because a CIDR block is always aligned to its own size. An address like .10 cannot start a block bigger than a /31, so a range that starts there needs several blocks of growing size.

What is the smallest CIDR block that covers a range?

The longest common prefix of the start and end addresses. For 192.168.1.10–192.168.1.200 that prefix is 24 bits.

How many addresses does a /N block have?

2^(32 − N). A /24 has 256, a /22 has 1,024 and a /32 has 1.

Can I turn a CIDR back into a range?

Yes, the subnet calculator shows the first and last address of any CIDR block. To see an address as a number, use the IPv4 address converter.

Report a problem