IPv4 range expander

What is an Ipv4 Range Expander?

Firewalls, cloud security groups and routing configurations usually expect networks in CIDR notation, such as 10.20.0.0/22, but ranges are often given as a start and end address. This tool takes a start and end IPv4 address and calculates the smallest single subnet that contains both, along with its CIDR notation, mask and size.

How to use it

  1. Enter the start IPv4 address.
  2. Enter the end IPv4 address.
  3. Read the resulting network, CIDR prefix, subnet mask and number of addresses.

Example

Start 192.168.1.10, end 192.168.1.200. In binary, the last octets are 00001010 and 11001000; they already differ in the first bit of the fourth octet, so only the first 24 bits are shared. The smallest covering subnet is 192.168.1.0/24, mask 255.255.255.0, 256 addresses.

How it works

Both addresses are converted to 32-bit numbers. The tool counts how many leading bits they have in common; that count is the prefix length. The network address keeps those common bits and sets the rest to zero.

Important: a covering subnet can be larger than the range

In the example, the subnet also includes 192.168.1.0 to 192.168.1.9 and 192.168.1.201 to 192.168.1.255, which were not in your range. If you need to cover exactly the range, it must be split into several CIDR blocks: 10 to 200 is exactly 192.168.1.10/31, .12/30, .16/28, .32/27, .64/26, .128/26, .192/29 and .200/32. Check carefully before allowing a larger block through a firewall.

Tip

Ranges that start on a power-of-two boundary and contain a power-of-two number of addresses map to exactly one CIDR block, for example 10.0.4.0 to 10.0.7.255 is exactly 10.0.4.0/22.

Frequently Asked Questions

How do I convert an IP range to CIDR?

Find the number of leading bits the start and end addresses share. That number is the prefix length of the smallest subnet that covers both.

Does the resulting subnet contain only my range?

Not always. The smallest covering subnet can include extra addresses. Exact coverage may need several CIDR blocks.

When does a range fit exactly into one CIDR block?

When it starts on a boundary that is a multiple of its size and its size is a power of two.

Is IPv6 supported?

This tool works with IPv4 addresses. Use the IPv6 subnet calculator for IPv6 networks.