← Back to All Guides

Demystifying CIDR & IP Subnetting: A Practical Guide for Developers

Whether configuring an AWS VPC security group, establishing Kubernetes Pod CIDR boundaries, or auditing firewall rules, developers encounter IP addresses with slash notation (like 10.0.0.0/16 or 192.168.1.0/24) every day.

To many engineers, subnet math feels unintuitive. In this guide, we break down the 32-bit architecture of IPv4, explain how binary bitwise AND operations partition networks, and provide clear formulas to calculate usable host ranges.

1. The Anatomy of an IPv4 Address

An IPv4 address is simply a 32-bit unsigned integer. To make it readable, humans write it as four 8-bit octets separated by dots (Dotted Decimal Notation):

IP Address: 192.168.1.10 Binary: 11000000 . 10101000 . 00000001 . 00001010 (Octet 1) (Octet 2) (Octet 3) (Octet 4)

2. What is CIDR Notation?

Historically, the Internet assigned addresses using rigid "Classes" (Class A, B, and C), which led to massive wastage of IPv4 address space. In 1993, Classless Inter-Domain Routing (CIDR) was introduced (RFC 1519).

The number following the slash (e.g. /24) indicates the prefix length: exactly how many leading bits belong to the Network ID, with the remaining bits belonging to individual Hosts.

CIDR Prefix Subnet Mask Total Addresses Usable Hosts
/32 255.255.255.255 1 1 (Single Host / Loopback)
/28 255.255.255.240 16 14
/24 255.255.255.0 256 254 (Standard Home/Office LAN)
/16 255.255.0.0 65,536 65,534 (Typical Cloud VPC)

3. Calculating Network and Broadcast Addresses

To find the network boundaries, the computer performs a bitwise AND between the IP address and the subnet mask:

IP: 11000000 . 10101000 . 00000001 . 00001010 (192.168.1.10) Mask: 11000000 . 11111111 . 11111111 . 00000000 (255.255.255.0 = /24) -------------------------------------------------------------- Network: 11000000 . 10101000 . 00000001 . 00000000 (192.168.1.0) Broadcast:11000000 . 10101000 . 00000001 . 11111111 (192.168.1.255)
Why \(2^{(32 - \text{CIDR})} - 2\)? In standard subnets, two addresses are reserved by the networking stack: the first address (all host bits 0) identifies the Network Address, and the last address (all host bits 1) is the Broadcast Address.

4. RFC 1918 Private IP Ranges

Certain IP address blocks are designated as non-routable on the public Internet, reserved for internal private networks:

Step-by-Step Bitwise AND Subnet Calculation Walkthrough

To truly understand how network routing equipment evaluates packet destinations, consider an incoming packet addressed to 192.168.10.45 with a subnet mask of 255.255.255.192 (a /26 CIDR prefix).

The network hardware converts both values into 32-bit binary registers:

IP Address: 192.168.010.045 -> 11000000.10101000.00001010.00101101 Subnet Mask: 255.255.255.192 -> 11000000.10101000.00001010.11000000 ------------------------------------------------------------------- Bitwise AND: 11000000.10101000.00001010.00000000 -> 192.168.10.0 (Network IP)

The remaining 6 bits represent host addresses (2^6 = 64 total addresses). The broadcast address is calculated by setting all 6 host bits to 1, producing 192.168.10.63. The usable host range spans strictly from 192.168.10.1 to 192.168.10.62.

Multi-Tier Cloud VPC Subnet Architecture Design

In production cloud engineering (AWS, GCP, Azure), best practices dictate architecting a 3-tier VPC network topology across multiple Availability Zones (AZs) for high availability and zero-trust security isolation:

5. Try Our Free Online Subnet Calculator

Calculate netmasks, binary bit visualizers, usable ranges, and CIDR prefixes locally:

🌐 Open IP Subnet & CIDR Calculator