Quick Answer: How to Calculate Usable Hosts in a CIDR Subnet
To calculate the number of usable hosts in an IPv4 CIDR block, use the formula 2^(32 - CIDR) - 2. For a /24 subnet, the calculation is 2^(32 - 24) - 2 = 2^8 - 2 = 254 usable hosts (with a subnet mask of 255.255.255.0). The first address (.0) is reserved for the network, and the last address (.255) is reserved for broadcast traffic.
Visual IPv4 32-Bit Binary Structure
An IPv4 address consists of 32 bits partitioned into Network Bits (routing prefix) and Host Bits (individual machines):
CIDR Prefix Reference Table (/16 to /30)
| CIDR Prefix | Subnet Mask | Total IPs | Usable Hosts (RFC) | 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 (Too small for VPC) |
Step-by-Step Case Study: Designing an AWS Multi-AZ VPC
Let's design a production-grade AWS VPC subnet topology starting from a primary parent block of 10.0.0.0/16:
- Public Web Subnets (/24 = 251 usable IPs each):
10.0.1.0/24in us-east-1a (Public NAT / ALB load balancers)10.0.2.0/24in us-east-1b (Public NAT / ALB load balancers) - Private Application Subnets (/22 = 1,019 usable IPs each):
10.0.4.0/22in us-east-1a (Kubernetes EKS worker nodes / microservices)10.0.8.0/22in us-east-1b (Kubernetes EKS worker nodes / microservices) - Isolated Database Subnets (/26 = 59 usable IPs each):
10.0.16.0/26in us-east-1a (Amazon Aurora PostgreSQL Primary)10.0.16.64/26in us-east-1b (Amazon Aurora PostgreSQL Read Replica)
RFC 1918 Private IP Ranges Reference
- 10.0.0.0/8: 10.0.0.0 to 10.255.255.255 (16,777,216 total addresses - standard for massive corporate datacenters & AWS VPCs).
- 172.16.0.0/12: 172.16.0.0 to 172.31.255.255 (1,048,576 total addresses - common default in Docker bridge networks).
- 192.168.0.0/16: 192.168.0.0 to 192.168.255.255 (65,536 total addresses - standard for home routers and small office LANs).
