Network · Developer

IP range to CIDR.

Turn a start and end IPv4 address into the fewest CIDR blocks that cover it exactly, expand a CIDR block into its first and last address, or see any IPv4 address as a decimal, hex and binary number.

Advertisement

Inputs

Result

Enter a value, then press Convert.

How it's calculated

An IPv4 address is four octets, a single unsigned 32-bit number (RFC 791). That number is the decimal form: 192.168.1.1 is 3,232,235,777. A CIDR block with prefix length n covers 232−n addresses that share the first n bits, so it must start on a multiple of its own size (RFC 4632).

Range to CIDR is greedy from the low end: take the largest block that is aligned at the current address and still fits inside the remaining range, emit it, move past it, repeat. That gives the minimum number of blocks, the same result as Python's ipaddress.summarize_address_range. CIDR to range zeroes the host bits for the first address and sets them for the last; if you type host bits (10.1.2.3/8), the tool normalizes to the network (10.0.0.0/8) and says so.

Specs: RFC 791 (32-bit addresses) and RFC 4632 (CIDR prefixes). Need the mask, wildcard or usable hosts for one subnet? Use the subnet calculator.

Worked example

Convert the range 192.168.1.10 to 192.168.1.200. As decimal numbers that is 3,232,235,786 to 3,232,235,976, which is 191 addresses. Greedy from the low end, the largest aligned block at each step is: 192.168.1.10/31 (2 addresses), 192.168.1.12/30 (4), 192.168.1.16/28 (16), 192.168.1.32/27 (32), 192.168.1.64/26 (64), 192.168.1.128/26 (64), 192.168.1.192/29 (8) and 192.168.1.200/32 (1). That is 8 blocks, and 2 + 4 + 16 + 32 + 64 + 64 + 8 + 1 = 191, so nothing is missed or counted twice. The first block is only a /31 because .10 is not a multiple of 4.

A shorter case: 10.0.0.1 to 10.0.0.6 takes four blocks (10.0.0.1/32, 10.0.0.2/31, 10.0.0.4/31, 10.0.0.6/32), because both ends sit on odd boundaries.

Common mix-ups

  1. RFC 4632: Classless Inter-domain Routing (CIDR), section 3.1

Checked against these sources on .

Frequently asked questions

Why does my range give several CIDR blocks?

A single CIDR block must be a power-of-two size starting on an aligned address. A range like 10.0.0.1 to 10.0.0.6 is neither, so it takes several blocks. The list shown is the shortest possible.

Does it include network and broadcast addresses?

Yes. The blocks cover every address from start to end inclusive, with no addresses reserved. For usable hosts of one subnet, use the subnet calculator.

Does this work for IPv6?

No, this tool is IPv4 only.

Sources

Last checked

Standards cited as published; the arithmetic and defaults are this tool’s own. Runs entirely in your browser. Nothing you type is sent or stored.

Pure arithmetic — no network access

Everything is computed in your browser. Nothing is looked up, and the tool does not check whether an address is routed or assigned.

Advertisement
Advertisement