Dev / IT8 min read

CIDR Notation and Subnetting: A Complete Guide

Master CIDR notation and subnetting. Learn how to calculate network addresses, host ranges, broadcast addresses, and usable IPs from any CIDR block.

What is CIDR Notation?

CIDR (Classless Inter-Domain Routing) notation is a compact way to represent an IP address and its associated network mask. It consists of an IP address followed by a slash and a prefix length number, like 192.168.1.0/24.

The prefix length (the number after the slash) indicates how many bits of the IP address represent the network portion. The remaining bits are used to identify individual hosts within that network.

Understanding IP Address Structure

An IPv4 address is 32 bits, written as four octets (groups of 8 bits) in decimal notation:

192.168.1.100
= 11000000.10101000.00000001.01100100
  ←─── 32 bits total ───────────────→

How the Prefix Length Works

In 192.168.1.0/24, the /24 means the first 24 bits are the network address and the remaining 8 bits identify hosts:

192.168.1.0/24
11000000.10101000.00000001 | 00000000
←────── Network (24 bits) ──────────→ ←── Host (8 bits) ──→

Key Subnet Calculations

From a CIDR block, you can calculate several important values:

ValueFormulaExample (/24)
Total addresses2^(32 - prefix)2^8 = 256
Usable hostsTotal - 2256 - 2 = 254
Network addressFirst IP in range192.168.1.0
Broadcast addressLast IP in range192.168.1.255
First usable hostNetwork + 1192.168.1.1
Last usable hostBroadcast - 1192.168.1.254

Common CIDR Blocks Reference

CIDRSubnet MaskTotal HostsUsable HostsCommon Use
/32255.255.255.25510Single host route
/30255.255.255.25242Point-to-point links
/29255.255.255.24886Small segments
/28255.255.255.2401614Small office
/27255.255.255.2243230Small department
/26255.255.255.1926462Medium subnet
/25255.255.255.128128126Large subnet
/24255.255.255.0256254Standard LAN
/23255.255.254.0512510Large LAN
/22255.255.252.01,0241,022Campus network
/16255.255.0.065,53665,534Large organization
/8255.0.0.016,777,21616,777,214ISP allocation

Private IP Address Ranges

RFC 1918 defines three ranges of private IP addresses for use within organizations:

RangeCIDRAddresses
10.0.0.0 – 10.255.255.25510.0.0.0/816,777,216
172.16.0.0 – 172.31.255.255172.16.0.0/121,048,576
192.168.0.0 – 192.168.255.255192.168.0.0/1665,536

Subnetting Example

Suppose you have the network 10.0.0.0/8 and need to divide it into smaller subnets for different departments:

Department A (500 hosts needed) → 10.1.0.0/23  (510 usable)
Department B (200 hosts needed) → 10.2.0.0/24  (254 usable)
Department C (50 hosts needed)  → 10.3.0.0/26  (62 usable)
Point-to-point link             → 10.4.0.0/30  (2 usable)

✓ Tip: To find the right prefix length for a required number of hosts, use the formula: prefix = 32 - ceil(log2(hosts + 2)). For 100 hosts: 32 - ceil(log2(102)) = 32 - 7 = /25 (126 usable hosts).

CIDR in Cloud Environments

CIDR notation is fundamental in cloud networking. When you create a VPC (Virtual Private Cloud) in AWS, Azure, or GCP, you assign a CIDR block that defines the IP address space for the entire virtual network. Subnets within the VPC are smaller CIDR blocks carved from the VPC range.

VPC:              10.0.0.0/16    (65,534 addresses)
Public Subnet:    10.0.1.0/24    (254 addresses)
Private Subnet:   10.0.2.0/24    (254 addresses)
Database Subnet:  10.0.3.0/24    (254 addresses)

TRY THE FREE TOOL

CIDR & Subnet Calculator

Subnet breakdown, host range & broadcast address

Open Tool →
← Back to all articles