Where CIDR came from

Before 1993 the IPv4 world was carved into fixed classes: Class A (/8), Class B (/16), Class C (/24). If your company outgrew a Class C, your only option was a full Class B - 65,536 addresses, far more than most needed. CIDR (RFC 4632, "Classless Inter-Domain Routing") replaced the rigid classes with arbitrary prefix lengths. Now you can have a /22 (1,024 addresses), a /28 (16 addresses), or anything in between.

The notation, decoded

A CIDR block is just address/prefix:

For 192.168.1.0/24:

192.168.1.0
↓ as 32 bits ↓
11000000.10101000.00000001.00000000
└──────── 24 network bits ─────┘└── 8 host bits ──┘

24 network bits + 8 host bits = 32 bits total (IPv4 is always 32 bits). The 8 host bits give you 28 = 256 addresses. Subtract 2 (network address + broadcast) and you get 254 usable hosts.

The subnet mask is just the prefix in disguise

Every CIDR prefix has an equivalent dotted-decimal mask. The first N bits are 1, the rest are 0:

CIDRSubnet maskTotal IPsUsable hosts
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/24255.255.255.0256254
/27255.255.255.2243230
/30255.255.255.25242
/31255.255.255.25422 (RFC 3021)
/32255.255.255.25511

The "usable hosts" formula is 2(32 − N) − 2 for /N ≤ 30. The two reserved addresses are the network address (all host bits 0) and the broadcast (all host bits 1). For /31 and /32 the rules change: /31 was redefined by RFC 3021 to allow 2 usable hosts on point-to-point links (no broadcast needed), and /32 represents a single host route.

Special "wildcard mask"

Some routing platforms (Cisco IOS, ACL syntax) use the inverted mask, called the wildcard mask. A /24's wildcard is 0.0.0.255 (the bits you don't care about). It's the same information; just flipped. Modern Linux iptables and most firewalls use the regular mask.

RFC 1918 - the private ranges everyone uses

Three IPv4 ranges are reserved for private use - they don't route on the public internet, and any organization can use them internally without coordinating with anyone:

Plus 100.64.0.0/10 (CGNAT - RFC 6598) for carrier-grade NAT, and 169.254.0.0/16 for link-local autoconfig.

Network address vs. broadcast vs. usable

For 192.168.1.0/24:

IPv6 - same idea, much bigger numbers

IPv6 addresses are 128 bits, written in 8 groups of 4 hex digits. Common prefix lengths:

IPv6 has no broadcast address. The all-ones-host pattern is just a regular unicast address. Multicast handles "send to many" needs differently. So the math for usable hosts in IPv6 is just 2(128 − N) with no -2 deduction.

VLSM and supernetting

Two CIDR-era concepts worth knowing:

JustKit's role

The JustKit CIDR calculator takes a CIDR block and returns the network/broadcast/host range, mask, wildcard, and binary breakdown - handy when you're staring at a network diagram or a firewall rule. Works for IPv4 and IPv6.