ThisCalculator

Everyday

CIDR Classless Inter-Domain Routing Explained

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

CIDR (Classless Inter-Domain Routing) is a method for allocating and routing IP addresses that replaces the older class-based system with variable-length network prefixes, allowing more efficient use of the IPv4 address space. You enter an IP address and a prefix length (like /24), and the calculator below shows the network address, broadcast address, usable host range, and total number of hosts for that subnet.

Formula

The core CIDR formula converts a prefix length P (in bits) into a subnet mask and address ranges. The number of addresses in the block is 2(32−P). The network address is obtained by setting all host bits (the bits after the prefix) to 0, and the broadcast address by setting them to 1. The usable host count is 2(32−P) − 2, subtracting the network and broadcast addresses.

Variables:

  • IP address – the IPv4 address you are subdividing, e.g., 192.168.1.0
  • Prefix length (P) – number of leading 1-bits in the subnet mask, from 0 to 32
  • Network address – first address of the block, identifies the subnet
  • Broadcast address – last address, used to send to all hosts on the subnet
  • Usable hosts – addresses available for devices, excluding network and broadcast

Worked Example

Using the defaults: IP 192.168.1.0 with a /24 prefix.

  1. Prefix length 24 means the first 24 bits are the network part, leaving 8 bits for hosts.
  2. Number of addresses = 2(32−24) = 28 = 256.
  3. Network address = 192.168.1.0 (all host bits 0).
  4. Broadcast address = 192.168.1.255 (all host bits 1).
  5. Usable hosts = 256 − 2 = 254.

The calculator returns exactly these values, confirming the /24 subnet provides 254 usable addresses, which is why it is the default for most local networks.

Background: Why CIDR Was Created

Before CIDR (introduced in 1993, RFC 1518 and 1519), IP addresses were allocated in fixed classes: Class A (/8), Class B (/16), and Class C (/24). This system wasted enormous amounts of address space—a company needing 300 addresses had to take a full Class B (65,534 usable), leaving most unused. By the early 1990s, the IPv4 address pool was draining fast, and routing tables were growing out of control. CIDR solved both by allowing any prefix length, not just 8, 16, or 24, and by enabling route aggregation (supernetting). For example, instead of advertising sixteen separate /24 routes, an ISP can advertise one /20 route covering all of them.

How CIDR Works

CIDR notation writes an IP address followed by a slash and the prefix length, e.g., 10.0.0.0/8. The prefix length tells you how many leading bits are fixed (the network part); the remaining bits are host bits. The subnet mask is derived by setting the first P bits to 1 and the rest to 0. For instance:

  • /8 → 255.0.0.0 (Class A equivalent)
  • /16 → 255.255.0.0 (Class B equivalent)
  • /24 → 255.255.255.0 (Class C equivalent)
  • /25 → 255.255.255.128 (half a Class C)
  • /30 → 255.255.255.252 (two usable addresses, typical for point-to-point links)

To find the network address, perform a bitwise AND between the IP and the mask. To find the broadcast, set all host bits to 1. The usable range is everything between them.

How to Choose a CIDR Prefix

Choosing the right prefix depends on how many hosts you need and how much growth you expect. A simple rule: usable hosts = 2(32−P) − 2. Common choices:

  • /30 – 2 usable addresses, ideal for a point-to-point link between two routers.
  • /29 – 6 usable, small branch office.
  • /28 – 14 usable, small VLAN.
  • /24 – 254 usable, standard for a small office or home LAN.
  • /16 – 65,534 usable, large enterprise or campus.
  • /8 – 16,777,214 usable, huge networks (e.g., 10.0.0.0/8 private).

Always leave room for growth—adding a few extra bits costs nothing and saves renumbering later. Also remember that the first and last addresses are not usable for hosts.

Common Problems and Misconceptions

One frequent mistake is confusing the number of addresses with usable hosts. A /31 gives 2 addresses but 0 usable by the standard rule; however, RFC 3021 allows /31 for point-to-point links where both addresses are used. Another misconception: the subnet mask is not the same as the prefix length—it is the dotted-decimal representation of the prefix bits. People also forget that CIDR works for both IPv4 and IPv6; in IPv6, the prefix length is written the same way (e.g., 2001:db8::/32). Finally, a common error in subnetting is forgetting that the network and broadcast addresses are not assignable, leading to an off-by-two mistake in host counts.

Comparison: CIDR vs. Classful Addressing

Classful addressing forced fixed boundaries at /8, /16, and /24. CIDR removes those boundaries, allowing any prefix length. The table below contrasts the two:

  • Flexibility – Classful is rigid; CIDR can match the exact size needed.
  • Efficiency – Classful wastes addresses; CIDR minimizes waste.
  • Routing tables – Classful requires many routes; CIDR aggregates routes, shrinking tables.
  • VLSM – CIDR enables Variable Length Subnet Masks, letting you subdivide a network into different-sized subnets.

Today, all internet routing uses CIDR. The classful system is only of historical interest, though the terms “Class A,” “B,” and “C” persist informally.

Limitations and Alternatives

CIDR’s main limitation is that it still relies on IPv4’s 32-bit address space, which is exhausted. The long-term alternative is IPv6, which uses 128-bit addresses and CIDR-like prefixes (e.g., /64 for a subnet). Network Address Translation (NAT) and private addressing (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) were stopgap measures to extend IPv4’s life, but they add complexity. For most internal networks, CIDR remains the standard way to plan subnets, and tools like this calculator simplify the math.

Frequently Asked Questions

What does /24 mean in CIDR?

/24 means the first 24 bits of the IP address are the network part, leaving 8 bits for hosts. This gives 256 total addresses, with 254 usable for devices. It is the most common prefix for home and small office networks.

How many usable hosts are in a /28 subnet?

A /28 has 32−28 = 4 host bits, so 24 = 16 addresses. Subtract 2 for network and broadcast, leaving 14 usable addresses. This is often used for small VLANs or cloud subnets.

What is the subnet mask for /26?

A /26 has 26 network bits, so the mask is 255.255.255.192. It provides 64 addresses, 62 usable, which is useful for a medium-sized office or a Wi-Fi network with many devices.

Can I use a /31 subnet for a point-to-point link?

Yes, RFC 3021 permits /31 subnets for point-to-point links, giving 2 usable addresses (no network or broadcast). This is common on router-to-router connections to save address space.

Why is CIDR called “classless”?

Because it abandons the fixed class boundaries (A, B, C) and allows any prefix length. The term distinguishes it from the older classful routing, which could only use /8, /16, or /24.

Related

Formula used
in ip | IP address | - | 192.168.1.0 | 0
in prefix | Prefix length | bits | 24 | 0
out network | Network address | - | 192.168.1.0 | 0
out broadcast | Broadcast address | - | 192.168.1.255 | 0
out hosts | Usable hosts | - | 2^(32-prefix)-2 | 0
out mask | Subnet mask | - | 255.255.255.0 | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.