X Xerobit

CIDR Notation Explained — What /24, /16, /8 Mean in IP Addresses

CIDR notation is the slash number after an IP address — /24, /16, /8. It specifies how many bits belong to the network portion. Here's how to read CIDR, calculate address...

Mian Ali Khalid · · 7 min read
Use the tool
Subnet / CIDR Calculator
Calculate IPv4 subnets — network, broadcast, usable range, wildcard mask. Input CIDR (/24) or dotted mask (255.255.255.0). Binary visualization.
Open Subnet / CIDR Calculator →

CIDR stands for Classless Inter-Domain Routing. The notation 192.168.1.0/24 means: an IP address (192.168.1.0) paired with a prefix length (/24). The prefix length tells you how many bits of the IP address are fixed (the network portion) and how many bits are variable (the host portion).

Use the Subnet Calculator to calculate CIDR ranges, subnet masks, and host counts from any CIDR block.

Reading CIDR notation

An IPv4 address is 32 bits. CIDR’s /n specifies that the first n bits identify the network.

192.168.1.0/24

Binary:  11000000.10101000.00000001.00000000
         │←──────── 24 bits ────────→│←8 bits→│
         Network portion               Host portion

The remaining 32 - n bits are available for hosts:

  • /24 → 8 host bits → 2⁸ = 256 addresses (254 usable)
  • /16 → 16 host bits → 2¹⁶ = 65,536 addresses
  • /8 → 24 host bits → 2²⁴ = 16,777,216 addresses

Two addresses per block are reserved: the network address (all host bits 0) and the broadcast address (all host bits 1), so usable hosts = 2^(32-prefix) − 2.

Common CIDR blocks

CIDRSubnet maskTotal IPsUsable hostsUse case
/32255.255.255.25511Single host route
/31255.255.255.25422Point-to-point links
/30255.255.255.25242Point-to-point with broadcast
/29255.255.255.24886Small network
/28255.255.255.2401614Small LAN
/27255.255.255.2243230Small office
/26255.255.255.1926462Medium network
/25255.255.255.128128126Half a class C
/24255.255.255.0256254Standard LAN (old class C)
/23255.255.254.0512510Two class C blocks
/22255.255.252.01,0241,022Small campus
/20255.255.240.04,0964,094Medium campus
/16255.255.0.065,53665,534Large network (old class B)
/8255.0.0.016,777,21616,777,214Entire class A block

Calculating the address range from CIDR

Given 192.168.5.0/22:

  1. Find the subnet mask: /22 → first 22 bits are 1s 11111111.11111111.11111100.00000000 = 255.255.252.0

  2. Find the network address: AND the IP with the subnet mask

    192.168.5.0   = 11000000.10101000.00000101.00000000
    255.255.252.0 = 11111111.11111111.11111100.00000000
    AND result    = 11000000.10101000.00000100.00000000
                  = 192.168.4.0

    Network address: 192.168.4.0

  3. Find the broadcast address: OR the network address with the inverted mask

    Inverted mask = 00000000.00000000.00000011.11111111
    Network       = 11000000.10101000.00000100.00000000
    OR result     = 11000000.10101000.00000111.11111111
                  = 192.168.7.255

    Broadcast: 192.168.7.255

  4. Usable range: 192.168.4.1 to 192.168.7.254 (1,022 hosts)

CIDR and cloud networking

CIDR blocks are fundamental to cloud network architecture.

AWS VPC

VPC: 10.0.0.0/16      (65,536 IPs — the whole space)
  Subnet A: 10.0.1.0/24  (256 IPs — one AZ, public)
  Subnet B: 10.0.2.0/24  (256 IPs — one AZ, private)
  Subnet C: 10.0.3.0/24  (256 IPs — another AZ, private)

AWS recommends /16 for VPCs (large enough to never run out). Subnets within a VPC are typically /24 (256 IPs) or /22 (1,024 IPs) depending on service density.

Security group rules

Security groups use CIDR for source/destination IP ranges:

  • 0.0.0.0/0 — allow all IPv4 (used for public-facing ports like 443)
  • 10.0.0.0/8 — allow all RFC 1918 private addresses
  • 10.0.1.0/24 — allow only a specific subnet
  • 192.168.5.32/32 — allow only a single IP

/0 means “no bits fixed” — the wildcard that matches any address. 0.0.0.0/0 in a rule means “from anywhere.”

Supernetting and route aggregation

CIDR allows aggregating multiple smaller blocks into one routing entry. This is the “classless” in CIDR — the original class A/B/C system wasted massive address space.

Example: An ISP assigns 203.0.113.0/24 to four customers as /26 blocks:

Customer 1: 203.0.113.0/26   (0–63)
Customer 2: 203.0.113.64/26  (64–127)
Customer 3: 203.0.113.128/26 (128–191)
Customer 4: 203.0.113.192/26 (192–255)

The ISP’s upstream router only needs one route: 203.0.113.0/24. The ISP aggregates all four /26 customers into a single /24 announcement.

IPv6 CIDR

IPv6 addresses are 128 bits. CIDR notation works identically, but prefix lengths are much larger:

  • /128 — single IPv6 host (equivalent to IPv4 /32)
  • /64 — standard subnet size for IPv6 (2⁶⁴ addresses)
  • /48 — typical allocation to an organization
  • /32 — typical ISP allocation
2001:db8::/32       — Documentation range
2001:db8:1::/48     — Single site
2001:db8:1:1::/64   — Single subnet

The /64 prefix is standard for IPv6 subnets because SLAAC (Stateless Address Autoconfiguration) requires a /64 to function. You never use IPv6 subnets smaller than /64 in practice.

Quick calculation reference

To find the number of addresses in a CIDR block:

addresses = 2^(32 - prefix_length)    // IPv4
addresses = 2^(128 - prefix_length)   // IPv6

To find which /24 block an IP belongs to:

import ipaddress
ip = ipaddress.ip_address('192.168.5.42')
network = ipaddress.ip_network('192.168.5.0/24')
print(ip in network)  # True

The Subnet Calculator handles all CIDR calculations: given any IP and prefix, it shows the network address, broadcast address, usable range, and host count.


Related posts

Related tool

Subnet / CIDR Calculator

Calculate IPv4 subnets — network, broadcast, usable range, wildcard mask. Input CIDR (/24) or dotted mask (255.255.255.0). Binary visualization.

Written by Mian Ali Khalid. Part of the Dev Productivity pillar.