What is IPv4 Subnetting and Classless Inter-Domain Routing (CIDR)?
An IPv4 address is a 32-bit numeric address expressed as four decimal octets separated by periods (e.g. 192.168.1.1). Subnetting is the architectural practice of subdividing a single large network into smaller, isolated sub-networks (subnets). Subnetting optimizes routing performance, reduces broadcast network congestion, and enforces security boundaries between departments, virtual machines, and cloud environments (such as AWS VPCs, Azure VNets, and Google Cloud subnets).
In 1993, the IETF standardized Classless Inter-Domain Routing (CIDR) under RFC 4632 to replace rigid class-based network allocations (Class A, B, and C). In CIDR notation, a forward slash followed by a prefix number (e.g. /24) defines the exact number of leading bits reserved for the network prefix, leaving the remaining bits for individual host devices.
The Mathematics of Subnet Calculations
Given a 32-bit IPv4 address with a prefix length n:
- Host Bits: H = 32 - n
- Total IP Addresses: 2^H = 2^(32 - n)
- Usable Host Addresses: 2^H - 2 (subtracting the Network ID and the Broadcast Address)
For instance, in a /24 subnet: 32 - 24 = 8 host bits. Total addresses = 2^8 = 256. Usable hosts = 256 - 2 = 254.
Comprehensive CIDR Prefix & Subnet Mask Reference Table
| CIDR Prefix | Subnet Mask | Total Addresses | Usable Hosts | Typical Cloud / Network Use Case |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | Large enterprise private networks (RFC 1918 10.0.0.0/8). |
| /16 | 255.255.0.0 | 65,536 | 65,534 | Standard AWS / Azure VPC root network block. |
| /20 | 255.255.240.0 | 4,096 | 4,094 | Kubernetes cluster pod network subnet. |
| /24 | 255.255.255.0 | 256 | 254 | Most common local LAN and public cloud web tier subnet. |
| /28 | 255.255.255.240 | 16 | 14 | Small isolated database cluster or DMZ subnet. |
| /30 | 255.255.255.252 | 4 | 2 | Point-to-point router links. |
| /32 | 255.255.255.255 | 1 | 1 | Single specific host route or firewall IP whitelist. |
RFC 1918 Private IPv4 Address Allocations
The Internet Assigned Numbers Authority (IANA) designated three blocks of IPv4 address space for private networks that are not routed on the public global Internet:
- 24-bit block (Class A):
10.0.0.0to10.255.255.255(10.0.0.0/8) - 20-bit block (Class B):
172.16.0.0to172.31.255.255(172.16.0.0/12) - 16-bit block (Class C):
192.168.0.0to192.168.255.255(192.168.0.0/16)
Frequently Asked Questions (FAQ)
Why does AWS reserve 5 IP addresses instead of 2 in each subnet?
In AWS VPC subnets, Amazon reserves the first 4 IP addresses and the last IP address (e.g. .0 for network ID, .1 for VPC router, .2 for AWS DNS, .3 for future use, and .255 for broadcast). Therefore, a /24 in AWS yields 251 usable IP addresses rather than 254.
What is a Wildcard Mask used for?
A wildcard mask (the inverse of a subnet mask) is used in Cisco IOS Access Control Lists (ACLs) and routing protocols (OSPF, EIGRP). A 0 bit means "match this bit exactly", while a 1 bit means "ignore this bit (wildcard)".