Understanding Classless Inter-Domain Routing (CIDR) and IPv4 Subnetting
Classless Inter-Domain Routing (CIDR) is the standard mechanism for allocating IP addresses and routing Internet Protocol packets across modern computer networks. Replaces the legacy classful network architecture (Class A, B, and C), CIDR allows network engineers to partition IP address spaces into variable-sized subnets using a bitmask prefix length.
Subnet Mask Bit Math
An IPv4 address consists of 32 binary bits divided into four 8-bit octets. The CIDR notation prefix (e.g., /24) defines how many high-order bits are reserved for the Network ID, leaving the remaining bits to identify individual Host Interfaces.
- Network Bits ($N$): Specified by the CIDR prefix length (e.g., $N = 24$ for
/24). - Host Bits ($H$): Calculated as $H = 32 – N$.
- Total IP Addresses: Derived as $2^H$.
- Usable Host Addresses: Derived as $2^H – 2$ (excluding the dedicated Network IP address and Broadcast IP address).
Standard Subnet Mask Reference Table
Common CIDR prefixes used in enterprise cloud networking (AWS VPCs, Azure VNets) and local area network partitioning:
- /24 (Subnet Mask 255.255.255.0): 8 host bits $\rightarrow$ 256 total IPs (254 usable hosts). Standard LAN default.
- /16 (Subnet Mask 255.255.0.0): 16 host bits $\rightarrow$ 65,536 total IPs (65,534 usable hosts). Large cloud VPC block.
- /28 (Subnet Mask 255.255.255.240): 4 host bits $\rightarrow$ 16 total IPs (14 usable hosts). Small container or microservice block.
- /30 (Subnet Mask 255.255.255.252): 2 host bits $\rightarrow$ 4 total IPs (2 usable hosts). Dedicated point-to-point router links.