How to Use This CIDR Calculator

The calculator offers two conversion modes, selectable from the dropdown menu.

  • CIDR to IP range: Enter an IP address and prefix length (the number after the slash). The tool will output the network address, broadcast address, subnet mask, network prefix, wildcard mask, and total number of usable hosts within that block.
  • IP range to CIDR: Provide the first and last IP addresses of your range. If the range aligns perfectly with CIDR block boundaries, you'll receive a single CIDR notation. If not, the calculator will decompose it into the minimum number of CIDR blocks required to cover that range exactly.

Each conversion displays detailed breakdowns of the underlying subnet mathematics, making it straightforward to understand how the transformation works.

Understanding CIDR Notation

CIDR notation was introduced in 1993 (RFC 1519) to replace the inefficient classful addressing system that wasted millions of IP addresses. It combines an IP address with a prefix length:

  • IP address: One of the four octets in standard dotted-decimal form (e.g., 172.16.0.0).
  • Prefix length: A number from 0 to 32, representing how many of the 32 bits in the IP address form the fixed network portion. The remaining bits are variable and can be assigned to individual hosts.

For example, in 10.0.0.0/16, the first 16 bits (10.0) identify the network, and the final 16 bits can assign addresses to 65,536 unique hosts. This compact notation eliminated the need for separate subnet mask fields and made IP allocation far more granular and efficient.

CIDR to IP Range Conversion

To extract an IP range from CIDR notation, you perform three steps: calculate the subnet mask from the prefix length, identify the network prefix by applying the mask to the given IP address, and use wildcard bits to determine the first and last usable addresses.

Subnet mask octet = 256 − 2^(8 − bits in octet)

Network prefix = IP address AND Subnet mask

First IP = Network prefix (with all host bits set to 0)

Last IP = Network prefix OR Wildcard mask (all host bits set to 1)

Usable hosts = 2^(32 − prefix length) − 2

  • Prefix length — The number after the slash in CIDR notation, indicating how many bits define the network portion (0–32).
  • Subnet mask — A 32-bit value where the first n bits are 1 and the remaining bits are 0; used to isolate the network address from an IP.
  • Wildcard mask — The bitwise complement of the subnet mask, showing which bits may vary within the network block.
  • Network prefix — The base IP address of the network, with all host bits zeroed out.

Converting an IP Range to CIDR

Reverse conversion—from IP range to CIDR—is more complex because not every IP range maps neatly to a single CIDR block. The calculator evaluates whether your range aligns with CIDR boundaries.

  • Aligned ranges: If the first IP address starts at a network boundary and the last IP ends exactly at a broadcast address, a single CIDR block covers it. For instance, 10.0.0.0 to 10.0.0.31 is perfectly captured by 10.0.0.0/27.
  • Unaligned ranges: If the range does not align, the calculator decomposes it into the smallest set of non-overlapping CIDR blocks. The range 10.0.0.1 to 10.0.0.31, for example, requires five separate blocks to cover it completely without gaps or overlap.

The tool performs all alignment checks and decomposition automatically, saving you manual bit-by-bit analysis.

Common CIDR Pitfalls and Best Practices

CIDR math trips up even experienced engineers; avoid these frequent mistakes and design patterns.

  1. Never forget the network and broadcast addresses — The first IP in a block is the network address and the last is the broadcast address—neither can be assigned to a host. A /24 network contains 256 addresses total, but only 254 are usable for devices (256 − 2).
  2. Prefix length 31 and 32 have special uses — A /31 (2 addresses, 0 usable by standard rules) is used for point-to-point links and treats both IPs as usable. A /32 is a host route and represents a single IP, typically used for loopback or single-server networks.
  3. IP ranges don't always collapse to one CIDR block — Arbitrary ranges like 10.0.0.5 to 10.0.0.200 require multiple CIDR blocks to represent exactly. Always verify range alignment before assuming a single block will suffice.
  4. Smaller prefix lengths mean larger networks — A /8 covers 16.7 million addresses, while a /30 covers only 4. Intuition often works backwards here; remember that the prefix length indicates network bits, not network size.

Frequently Asked Questions

What is the fundamental difference between CIDR and classful IP addressing?

Classful addressing enforced rigid address classes (A, B, C) that allocated IP space in large, wasteful chunks. CIDR eliminates these classes and allows prefix lengths of any bit boundary from 0 to 32, enabling much finer-grained allocation. This flexibility prevents address exhaustion and lets organizations request exactly the address space they need, neither more nor less.

How do I determine how many hosts fit in a CIDR block?

Use the formula 2^(32 − prefix length) − 2. For a /24 network, that is 2^8 − 2 = 254 usable addresses. The two subtracted addresses are the network address (first) and broadcast address (last). Special cases exist: /31 blocks (point-to-point links) and /32 (single host routes) use different counting rules in practice.

Why might an IP range require multiple CIDR blocks?

An IP range maps to a single CIDR block only if it aligns perfectly with CIDR boundaries. The first IP must be a valid network address for some prefix length, and the last IP must be the corresponding broadcast address. If either condition fails—such as a range from 192.168.0.5 to 192.168.0.100—the calculator must decompose the range into multiple non-overlapping blocks to cover it exactly.

What does the wildcard mask represent, and when would I use it?

The wildcard mask is the bitwise inverse of the subnet mask; it shows which bits can vary within a network block. In access control lists (ACLs) and routing rules, wildcard masks are often used instead of CIDR notation. For example, the CIDR block 10.0.0.0/24 is expressed as address 10.0.0.0 with wildcard 0.0.0.255 in Cisco IOS and similar systems.

Can CIDR notation be used for both IPv4 and IPv6?

Yes, CIDR notation applies to both. IPv4 CIDR uses prefix lengths from 0 to 32 bits. IPv6 extends this to 0 to 128 bits, given IPv6's much larger address space. The fundamental concept remains the same: the prefix length indicates the fixed network portion, and the remaining bits are assigned to hosts or subnets.

What is 10.0.0.0/8, and how many addresses does it contain?

10.0.0.0/8 is a Class A private network block that spans from 10.0.0.0 to 10.255.255.255, totaling 16,777,216 unique addresses. It is one of three large private IP ranges reserved by RFC 1918 for internal use. The /8 prefix means only the first octet (10) is fixed; all remaining 24 bits can address individual hosts or further subnets.

More other calculators (see all)