IPv4 Subnetting Mathematics & CIDR Bit Allocation
An IPv4 address consists of 32 bits divided into a Network portion and a Host portion. In Classless Inter-Domain Routing (CIDR), the prefix (e.g., /24) denotes the number of consecutive leading bits dedicated to network identification.
1. Usable Host Capacity Equation
Usable Hosts=2(32 − CIDR Prefix)−2 (Network & Broadcast IPs)
2. Wildcard Mask & Subnet Inversion
Wildcard Mask=255.255.255.255−Subnet Mask
Step-by-Step Calculation Breakdown
Step 1: Partition 32 Bits for /24 Prefix
Network Bits = 24 Bits | Host Bits = 32 − 24 = 8 Bits
Total IP Block Size = 28 = 256 Total Addresses
Total IP Block Size = 28 = 256 Total Addresses
Step 2: Reserve Network and Broadcast Boundaries
Network Address = 192.168.1.0 (First IP in range)
Broadcast Address = 192.168.1.255 (Last IP in range)
Step 3: Determine Usable Host Range
Usable Range=192.168.1.1 to 192.168.1.254 (254 Usable Hosts)
CIDR Prefix Reference Table (/16 to /30)
| CIDR | Subnet Mask | Total IPs | RFC Usable Hosts | AWS VPC Usable |
|---|---|---|---|---|
| /16 | 255.255.0.0 | 65,536 | 65,534 | 65,531 |
| /20 | 255.255.240.0 | 4,096 | 4,094 | 4,091 |
| /24 | 255.255.255.0 | 256 | 254 | 251 |
| /26 | 255.255.255.192 | 64 | 62 | 59 |
| /28 | 255.255.255.240 | 16 | 14 | 11 |
| /30 | 255.255.255.252 | 4 | 2 | 0 (VPC Minimum /28) |