CIDR Explained

CIDR (Classless Inter-Domain Routing), defined in RFC 4632, is the notation system that replaced rigid classful addressing in 1993. Instead of being forced into /8, /16, or /24 blocks (classes A, B, and C), CIDR lets you write any prefix length from /0 to /32. This flexibility is what makes modern subnetting, route aggregation, and VLSM possible. Use the CIDR calculator to convert between prefixes and masks interactively.

Built by a network engineerCalculations run locally in your browserNo signup requiredNetwork information is not transmitted to our servers

The CIDR format

A CIDR block is written as address/prefix, where the prefix is the number of leading bits that form the network portion. For example, 10.0.0.0/8 means the first 8 bits are the network and the remaining 24 bits are host addresses.

10.0.0.0/8        →  network bits: 8,   host bits: 24
172.16.0.0/12     →  network bits: 12,  host bits: 20
192.168.1.0/24    →  network bits: 24,  host bits: 8
203.0.113.0/28    →  network bits: 28,  host bits: 4

From classful to classless

Before CIDR, the first octet determined the class and therefore the mask. A network starting with 192 had to be a /24, whether you needed 254 hosts or 10. This wasted enormous numbers of addresses. CIDR decoupled the mask from the address, so the same 192.0.2.0 block can be a /28 (14 hosts) or a /23 (510 hosts) as needed.

ClassLeading bitsDefault prefixRange (first octet)
A0/81–126
B10/16128–191
C110/24192–223
D (multicast)1110n/a224–239
E (reserved)1111n/a240–255

These classes are now historical. Modern routers and operating systems ignore them and use only the explicit prefix.

Converting a prefix to a dotted-decimal mask

The prefix is the count of 1-bits. Split it into octets: the first prefix ÷ 8 octets are 255, the next octet is a partial value, and the rest are 0.

Bits in octetValue
00
1128
2192
3224
4240
5248
6252
7254
8255

For /28: 28 ÷ 8 = 3 full octets (255.255.255) plus 4 bits. Four bits = 240, so the mask is 255.255.255.240.

Host capacity by prefix

PrefixMaskTotal addressesUsable hosts
/30255.255.255.25242
/29255.255.255.24886
/28255.255.255.2401614
/27255.255.255.2243230
/26255.255.255.1926462
/25255.255.255.128128126
/24255.255.255.0256254
/23255.255.254.0512510
/22255.255.252.010241022

The formula is 2^(32 − prefix) − 2. See the CIDR cheat sheet for the full table from /0 to /32.

Real-world usage

Routing tables

# A single /22 summary replaces four /24s
192.168.0.0/22  via 10.0.0.1
# Instead of:
192.168.0.0/24  via 10.0.0.1
192.168.1.0/24  via 10.0.0.1
192.168.2.0/24  via 10.0.0.1
192.168.3.0/24  via 10.0.0.1

Firewall rules (iptables)

iptables -A INPUT -s 10.50.0.0/16 -j ACCEPT
iptables -A INPUT -s 198.51.100.0/24 -p tcp --dport 443 -j ACCEPT

Cloud security groups

# Allow internal management subnet only
ingress {
  from_port = 22
  to_port   = 22
  protocol  = "tcp"
  cidr_blocks = ["10.20.30.0/26"]
}

CIDR vs wildcard masks

CIDR prefixes and subnet masks use contiguous 1-bits for the network. Cisco ACLs and OSPF use wildcard masks, which are the bitwise inverse — 0-bits match and 1-bits ignore. A /24 (255.255.255.0) becomes wildcard 0.0.0.255. See Wildcard Masks Explained for the full conversion method and the wildcard mask calculator.

Related guides & tools

Technically Reviewed By

Senior Enterprise Network Engineer — 25+ years of IT and network infrastructure experience, including enterprise Cisco switching, routing, wireless, firewalls, VPN, network access control, SD-WAN, and large-scale network operations.

Last reviewed: 2026-09-02

Calculations are performed using standards-based formulas and verified against known reference values. All computation runs client-side in your browser.