Networking Basics January 2025 · 6 min read

CIDR Notation Explained: The Math Behind /24, /16, and Beyond

Understanding what those slash numbers actually mean and how to work with them confidently.

You see it everywhere: 192.168.1.0/24, 10.0.0.0/8, 172.16.0.0/12. But what do those numbers after the slash actually mean? Let's break down CIDR notation from first principles.

The Basics: 32 Bits

An IPv4 address is 32 bits long. When we write 192.168.1.1, we're really writing a 32-bit binary number in a human-readable format. Each of the four octets represents 8 bits:

192.168.1.1 = 11000000.10101000.00000001.00000001

The CIDR number tells you how many of those 32 bits define the network portion. The remaining bits define the host portion.

What /24 Really Means

A /24 means the first 24 bits are the network, leaving 8 bits for hosts:

Network:  NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH
          (24 network bits)        (8 host bits)

With 8 host bits, you get 2^8 = 256 addresses (254 usable after removing network and broadcast).

Subnet Calculator Convert CIDR to subnet mask and calculate host ranges

The CIDR Quick Reference

CIDR Subnet Mask Total IPs Usable Hosts
/32255.255.255.25511
/31255.255.255.25422*
/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
/16255.255.0.065,53665,534
/8255.0.0.016,777,21616,777,214

*Note: /31 is a special case for point-to-point links (RFC 3021)

The Math Shortcut

To calculate hosts from CIDR: 2^(32 - CIDR) = total addresses

  • /24: 2^(32-24) = 2^8 = 256 addresses
  • /20: 2^(32-20) = 2^12 = 4,096 addresses
  • /27: 2^(32-27) = 2^5 = 32 addresses

Subtract 2 for usable hosts (network and broadcast addresses).

Why CIDR Replaced Classful Networking

Before CIDR, networks were divided into classes:

  • Class A: /8 (16 million hosts)
  • Class B: /16 (65,000 hosts)
  • Class C: /24 (254 hosts)

This was wasteful. A company needing 1,000 addresses had to get a Class B (65,000 addresses) because Class C was too small. CIDR allows any prefix length, so you can allocate exactly what's needed—like a /22 with 1,022 usable addresses.

Working Backwards: IP to Network

Given 192.168.1.50/26, what's the network address? The /26 mask has these boundaries:

  • 192.168.1.0 - 192.168.1.63
  • 192.168.1.64 - 192.168.1.127
  • 192.168.1.128 - 192.168.1.191
  • 192.168.1.192 - 192.168.1.255

Since 50 falls in the first range, the network is 192.168.1.0/26.

The pattern: with /26, networks start at multiples of 64 (256/4 blocks). With /27, they start at multiples of 32. With /28, multiples of 16, and so on.