You don't have javascript enabled. Please enable javascript to use this website.

IP Range to CIDR Converter

Convert a start and end IP address into the minimal set of CIDR blocks for any IPv4 or IPv6 range.
IPv4 (e.g. 10.0.0.0) or IPv6 (e.g. 2001:db8::)
Must be the same version as the start IP and ≥ start IP
CIDR Block IP Count
More Tools

IP Range to CIDR Converter — Convert Any Address Range to CIDR Notation

IP range to CIDR conversion computes the minimal set of CIDR blocks (RFC 4632) that exactly cover a start-to-end IPv4 or IPv6 address range. The algorithm selects the largest power-of-2 block aligned to a binary boundary at the current address, records it, advances past that block, and repeats until the entire range is covered. A range spanning a non-power-of-2 address count or starting at a non-boundary address produces multiple CIDR blocks — each covering a precisely aligned portion of the full range.

PropertyDetail
Protocol StandardRFC 4632 — Classless Inter-Domain Routing (CIDR)
InputStart IP + End IP — IPv4 or IPv6, same version required
AlgorithmGreedy binary-alignment: largest power-of-2 block per step
Typical Output1 block (aligned range) — up to 32 blocks (IPv4 worst case)
IPv4 Block Sizes/0 (4,294,967,296 addresses) to /32 (1 address)
IPv6 Block Sizes/0 (2¹²⁸ addresses) to /128 (1 address)
CalculationClient-side JavaScript — no server round-trip, no data stored

What the Results Mean

ColumnMeaningExample
CIDR Block An IP address combined with a prefix length (the /N suffix), defining the network. The prefix length determines how many leading bits are fixed — the remaining bits identify individual hosts within the block. 192.168.1.0/24
IP Count Total IP addresses in this block — 2^(32−N) for IPv4, 2^(128−N) for IPv6. Summing all rows must equal (end IP − start IP + 1). 256

How IP Range to CIDR Conversion Works

The conversion implements the greedy CIDR aggregation algorithm described in RFC 4632 (Classless Inter-Domain Routing — CIDR: The Internet Address Assignment and Aggregation Plan, September 2006). Starting at the first IP address — represented as a 32-bit integer for IPv4 or a 128-bit integer for IPv6 — the algorithm finds the maximum bit offset n such that: (1) the current address is evenly divisible by 2n (binary boundary alignment), and (2) the block of 2n addresses does not extend past the end address. The current address and prefix length (32−n for IPv4, 128−n for IPv6) form the next CIDR entry. The current address advances by 2n and the loop repeats until the current address exceeds the end address.

Binary boundary alignment is why arbitrary ranges produce multiple blocks. A /24 block (256 addresses) must start at an address where the last octet is 0. A /25 block (128 addresses) must start where the last octet is 0 or 128. A range starting at 10.0.0.1 cannot begin with any block larger than /32 at that address, because 1 is not divisible by any power of 2 greater than 1. The algorithm handles this by starting with the smallest valid block at the non-aligned start, then progressively selecting larger blocks as the current address advances to aligned positions.

The tool accepts IPv4 ranges up to the full /0 block (4,294,967,296 addresses) and IPv6 ranges up to /0 (2128 addresses). Input validation rejects mixed-version pairs (e.g. an IPv4 start with an IPv6 end) and ranges where the start IP is greater than the end IP.


IP Range to CIDR Converter

Convert a start and end IP address into the minimal set of CIDR blocks for any IPv4 or IPv6 range.

1

Enter the Start IP Address

Type the first IP address of the range — IPv4 (e.g. 10.0.0.0) or IPv6 (e.g. 2001:db8::). Both inputs must be the same IP version.
2

Enter the End IP Address

Type the last IP address of the range. The end IP must be greater than or equal to the start IP and must be the same version — you cannot mix IPv4 and IPv6 in one conversion.
3

Click Generate CIDR Blocks

The tool applies a greedy binary-alignment algorithm (RFC 4632) client-side and returns the minimal set of CIDR blocks that exactly cover your specified range.
4

Review the CIDR Block Table

Each row shows one CIDR block and the number of IP addresses it covers. Click Copy next to any individual block, or use Copy All to export every block at once.

Common Uses for IP Range to CIDR Conversion

Firewall rule generation. A network security engineer must block traffic originating from a provider's published IP range — for example, 203.0.113.0 to 203.0.114.255. Entering this range produces two /24 CIDR blocks (203.0.113.0/24 and 203.0.114.0/24), ready to paste directly into iptables, pfSense, or an AWS Security Group ingress rule without manual calculation or risk of off-by-one errors.

Cloud infrastructure access control. A DevOps engineer configuring an Azure Network Security Group must allow access from a vendor's IP allocation. Vendors commonly publish their ranges as start–end pairs in documentation or security advisories. Converting those pairs to CIDR notation produces the exact format required by cloud provider access-control APIs, which accept only CIDR input.

Routing table aggregation. A network administrator consolidating BGP routing tables receives legacy route entries documented as start/end pairs from a decommissioned system. Converting each pair to CIDR blocks produces the compact notation needed to configure BGP peers, reduce the number of route advertisements (route summarization per RFC 4632), and minimize router memory consumption.


Frequently Asked Questions

Why does my IP range produce multiple CIDR blocks instead of one?
Not all IP ranges align to a single CIDR block. A CIDR block must start at a binary boundary — an address where the last (32−N) bits are zero for IPv4 — and must contain exactly a power-of-2 number of addresses. Ranges that start mid-block or span a non-power-of-2 count require multiple blocks. For example, 10.0.0.1–10.0.0.14 produces four CIDR blocks because no single block can start at .1 without violating binary alignment.
What is the difference between this tool and the Subnet Calculator?
The Subnet Calculator takes a CIDR block (e.g. 192.168.1.0/24) as input and returns full network details — network address, broadcast address, subnet mask, wildcard, and usable host range. This tool works in the opposite direction: it takes a start IP and end IP and returns the minimal set of CIDR blocks that exactly cover that range. The two tools are complementary inverses of each other.
How accurate is the CIDR output — does it cover exactly my range without extra IPs?
Yes. The greedy algorithm (RFC 4632) finds the largest valid block at each step and advances precisely to the next uncovered address. The combined CIDR blocks cover exactly your specified range with no gaps and no extra addresses. Verify by summing the IP counts across all output rows — the total must equal (end IP − start IP + 1).
Do you store or log the IP addresses I enter?
No. All calculation runs entirely in your browser using client-side JavaScript. No start IP, end IP, or any other input data is transmitted to a server. Nothing is stored or logged.
Does the tool support IPv6 ranges?
Yes. Enter any valid IPv6 addresses in both fields — compressed notation such as 2001:db8:: is accepted. Both inputs must be the same version; mixing IPv4 and IPv6 in a single conversion returns a validation error. The algorithm handles IPv6 using 128-bit integer arithmetic, producing blocks such as 2001:db8::/32.

Related Guides

Guide What Is an IP Address?
covers the structure of IPv4 and IPv6 addresses, the meaning of network and host portions, and how CIDR prefix lengths relate to subnet boundaries.
Guide What Is IPv4?
explains the 32-bit address space, dotted-decimal notation, and why CIDR (RFC 4632) replaced classful addressing to slow IPv4 exhaustion.
Guide What Is IPv6?
covers the 128-bit address space, hexadecimal colon notation, and how IPv6 CIDR prefixes work with the same binary-alignment principles as IPv4.