When engineers configure cloud environments, design corporate networks, or troubleshoot connectivity issues, they inevitably run into IP addresses, subnets, and mysterious suffixes like /24 or /32. For non-network engineers, these concepts often feel like a black box. Understanding how subnets and CIDR notation work explained from the ground up empowers software developers, DevOps practitioners, and system administrators to design better architectures and communicate effectively with network teams.
The Foundations of IP Addressing
Before diving into subnets, it is essential to understand standard Internet Protocol version 4 (IPv4) addresses. An IPv4 address is a 32-bit number typically represented in dotted-decimal notation, consisting of four numbers separated by periods (e.g., 192.168.1.10).
Each of the four numbers is an octet representing 8 bits, yielding values between 0 and 255. Under the hood, computers do not see decimal numbers; they see a continuous string of 32 binary digits (ones and zeros). For example, the IP address 192.168.1.1 translates in binary to:
11000000.10101000.00000001.00000001
Every IP address is structurally split into two distinct parts:
- The Network Portion: Identifies the specific local network or subnet the device belongs to.
- The Host Portion: Identifies the specific device (host) residing on that network.
What is Subnetting and Why Do We Need It?
In the early days of the internet, networks were divided into rigid classes (Class A, B, and C). This approach was horribly inefficient and quickly led to IPv4 address exhaustion. Subnetting solves this problem by taking a single large network and dividing it into smaller, manageable sub-networks (subnets).
Imagine an office building with 500 employees. Placing all 500 computers on one giant broadcast network would result in constant network congestion, security vulnerabilities, and chaotic traffic management. By using subnets, an architect can logically partition the building into smaller zones—such as separating engineering, human resources, and guest Wi-Fi—enhancing both performance and security.
Decoding CIDR Notation
Historically, network engineers used a separate 32-bit pattern called a subnet mask (e.g., 255.255.255.0) to determine where the network portion ended and the host portion began. While functional, subnet masks are bulky and prone to misconfiguration.
Introduced in the 1990s, CIDR (Classless Inter-Domain Routing) revolutionized IP addressing. CIDR notation appends a slash (/) and a number to the end of an IP address (e.g., 192.168.1.0/24).
The number after the slash represents the prefix length—specifically, the exact number of bits set to 1 from the left of the 32-bit address, designating the network portion. A /24 means the first 24 bits are locked down for the network, leaving the remaining 8 bits (32 – 24 = 8) for host addresses.
Calculating Hosts in a CIDR Block
To find out how many usable IP addresses a specific CIDR block provides, use the formula $2^{(32 – n)}$, where $n$ is the CIDR prefix length.
- /30: $32 – 30 = 2$ bits for hosts. $2^2 = 4$ total addresses (commonly used for point-to-point links).
- /24: $32 – 24 = 8$ bits for hosts. $2^8 = 256$ total addresses (standard office or cloud VPC subnet).
- /16: $32 – 16 = 16$ bits for hosts. $2^{16} = 65,536$ total addresses (large corporate or cloud virtual network).
Note that in every subnet, two IP addresses are always reserved and cannot be assigned to hosts: the network address (the very first IP, where the host bits are all zeros) and the broadcast address (the very last IP, where the host bits are all ones). Therefore, a /24 network yields 256 total addresses, but only 254 usable host addresses.
Practical Example in Cloud Architecture
When provisioning resources in cloud platforms like AWS, Google Cloud, or Azure, you must define a Virtual Private Cloud (VPC) with a broad CIDR block (e.g., 10.0.0.0/16) and carve it into smaller subnets:
- Public Subnet (
10.0.1.0/24): Houses load balancers and web servers exposed to the public internet. - Private Subnet (
10.0.2.0/24): Houses application backend services isolated from direct inbound internet traffic. - Database Subnet (
10.0.3.0/24): Houses sensitive database clusters with strict internal-only access rules.
Frequently Asked Questions
What is the difference between a /24 and a /32 subnet?
A /24 subnet allocates 24 bits for the network and 8 bits for hosts, providing 256 total addresses. A /32 subnet allocates all 32 bits to the network portion, meaning it represents a single, isolated IP address with no room for additional hosts, commonly used for loopback interfaces or specific host route configurations.
Why are two IP addresses unusable in every subnet?
The first IP address in any subnet range is designated as the network identifier, and the final IP address is reserved for broadcasting packets to all devices on that segment. Routers and networking protocols rely on these fixed conventions to route traffic correctly.
Can a subnet mask be converted directly to CIDR notation?
Yes. Count the total number of consecutive 1 bits in the binary representation of the subnet mask. For instance, the traditional subnet mask 255.255.255.0 translates in binary to twenty-four 1 bits followed by eight 0 bits, which equates directly to /24 in CIDR notation.
Conclusion and Next Steps
Mastering subnets and CIDR notation bridges the gap between software development and infrastructure operations. By understanding how bits dictate network boundaries and host capacities, you can design cleaner VPC topologies, troubleshoot routing anomalies with confidence, and optimize resource allocation.
Ready to put theory into practice? Audit your current cloud infrastructure or container network configurations today to ensure your CIDR blocks are appropriately sized for future scalability without unnecessary address waste.
Recommended Hardware for This Setup
Tested, power-efficient gear curated for 24/7 home servers, Docker containers, and local labs.
Intel N100 Mini PC (16GB RAM, 500GB SSD)
Whisper-quiet, ultra-low 6W idle power. The undisputed favorite for 24/7 Docker, Jellyfin hardware transcoding, and Proxmox.
Raspberry Pi 5 (8GB Starter Kit)
Blazing quad-core ARM performance. Ideal for dedicated Pi-hole ad-blocking, WireGuard mesh nodes, and lightweight automation.
Crucial P3 Plus 1TB/2TB PCIe 4.0 NVMe
Up to 5000MB/s speeds. Essential for high-IOPS database operations, Docker container images, and snappy Nextcloud sync.
TP-Link 8-Port Gigabit Switch (TL-SG108)
Silent fanless steel housing, plug-and-play, traffic prioritization (QoS). Essential for wiring up your Home Server, NAS, and Pi with zero Wi-Fi lag.
Disclosure: BriteHacks is reader-supported. When you buy through links on our site or deploy infrastructure, we may earn an affiliate commission at no extra cost to you. As an Amazon Associate, we earn from qualifying purchases.