Visual IPv4 CIDR & Subnet Calculator
Calculate network address, broadcast address, netmask, wildcard mask, usable host IP ranges, and RFC 1918 classification in real time with visual bitmask decomposition. 100% client-side execution.
11000000.10101000.00000001.00110010
11000000.10101000.00000001.00110010
11000000.10101000.00000001.00000000
11000000.10101000.00000001.11111111
Demystifying Classless Inter-Domain Routing (CIDR) & IPv4 Subnetting
Classless Inter-Domain Routing (CIDR), introduced in 1993 via RFC 1518 and RFC 1519, replaced the legacy Classful network architecture (Class A, B, and C). The classful addressing scheme caused disastrous address space allocation inefficiencies—a Class B network allocated an unchangeable 65,536 addresses, even if an organization only required 500 hosts, rapidly accelerating IPv4 exhaustion.
Under CIDR, an IPv4 address is coupled with a variable-length prefix delimiter (denoted by a forward slash followed by a bit length, e.g., /24). This prefix specifies exactly how many of the 32 bits represent the Network ID, leaving the remainder to designate unique Host IDs. This enables fine-grained subnet division, aggregation (supernetting), and scalable BGP routing table compression across global Tier-1 Internet backbones.
Mathematical Bitwise Formulas for Subnet Calculation
Total Addresses = 2^(32 - Prefix) Usable Hosts = 2^(32 - Prefix) - 2 [For Prefix <= 30] Subnet Mask = (0xFFFFFFFF << (32 - Prefix)) & 0xFFFFFFFF Network Address = IP_INT & Subnet_Mask Broadcast Addr = Network_Address | (~Subnet_Mask & 0xFFFFFFFF)
Master IPv4 CIDR Subnet Cheat Sheet (/0 to /32)
The following authoritative reference table details every prefix length in the IPv4 addressing scheme, including subnet masks, wildcard masks, total addresses, and usable host capacities:
| CIDR Prefix | Subnet Mask | Wildcard Mask | Total Addresses | Usable Host Capacity | Common Cloud / Infrastructure Use Case |
|---|---|---|---|---|---|
/32 |
255.255.255.255 | 0.0.0.0 | 1 | 1 (Single Host / Loopback) | Firewall allowlist rule, host route, VPN peer endpoint |
/31 |
255.255.255.254 | 0.0.0.1 | 2 | 2 (RFC 3021 Point-to-Point) | Point-to-point router links (no network/broadcast lost) |
/30 |
255.255.255.252 | 0.0.0.3 | 4 | 2 | Legacy point-to-point links (WAN links, GRE tunnels) |
/29 |
255.255.255.248 | 0.0.0.7 | 8 | 6 | Public static IP blocks, redundant HA firewall clusters |
/28 |
255.255.255.240 | 0.0.0.15 | 16 | 14 (AWS reserves 5 -> 11) | Small database subnets, bastion host DMZ |
/27 |
255.255.255.224 | 0.0.0.31 | 32 | 30 (AWS: 27) | Microservice tiers, internal load balancers |
/26 |
255.255.255.192 | 0.0.0.63 | 64 | 62 | Mid-sized application cluster subnets |
/25 |
255.255.255.128 | 0.0.0.127 | 128 | 126 | Half-Class C allocation |
/24 |
255.255.255.0 | 0.0.0.255 | 256 | 254 (AWS: 251) | Standard office LAN, default cloud availability zone subnet |
/23 |
255.255.254.0 | 0.0.1.255 | 512 | 510 | High-density corporate wireless LAN |
/22 |
255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 | Kubernetes worker node subnets (EKS / GKE) |
/20 |
255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 | Enterprise cloud VPC Tier / Data center pod |
/16 |
255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 | AWS VPC standard root block, large enterprise datacenter |
/12 |
255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 | Entire Class B Private RFC 1918 block (172.16.0.0/12) |
/8 |
255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 | Entire Class A Private RFC 1918 block (10.0.0.0/8) |
/0 |
0.0.0.0 | 255.255.255.255 | 4,294,967,296 | All IPv4 Internet | Default gateway route (0.0.0.0/0) |
Cloud VPC IP Subnetting Architecture: AWS vs Azure vs GCP
When designing Virtual Private Clouds (VPCs) in hyperscale cloud providers, network engineers must account for vendor-specific IP reservation policies. Unlike on-premises bare-metal networks where only 2 addresses are lost per subnet (the Network ID and Broadcast Address), cloud providers reserve additional host addresses for hypervisor routing and infrastructure DNS:
| Cloud Provider | Reserved IPs per Subnet | Specific Reserved Offset Positions | Practical Usable Impact (on /28 Subnet) |
|---|---|---|---|
| Amazon Web Services (AWS VPC) | 5 Addresses |
.0: Network ID.1: VPC Router.2: AmazonProvidedDNS (Route 53 Resolver).3: AWS Future Use.255: Network Broadcast
|
16 total - 5 reserved = 11 usable IPs |
| Microsoft Azure (VNet) | 5 Addresses |
.0: Network ID.1: Default Gateway.2, .3: Azure DNS Mapping.255: Network Broadcast
|
16 total - 5 reserved = 11 usable IPs |
| Google Cloud Platform (GCP VPC) | 4 Addresses (2 per subnet + 2 per network) |
.0: Network ID.1: Default Gateway.254: Second-to-last (Metadata server).255: Broadcast
|
16 total - 4 reserved = 12 usable IPs |
Production Failure Modes: Real-World Outage Case Studies
1. The Overlapping CIDR Block Trap in Mergers & VPC Peering
A frequent disaster scenario in growing enterprises occurs when two corporate networks or cloud VPCs need to be connected via AWS Transit Gateway, VPC Peering, or IPSec VPN, only for engineers to discover that both environments were provisioned using the default 172.31.0.0/16 or 10.0.0.0/16 CIDR block.
- The Technical Failure: Standard IP routing relies on destination subnet uniqueness. When overlapping CIDR ranges exist, IP routing tables encounter non-deterministic path selection or hard routing drops, making bi-directional peering impossible.
- Mitigation Strategy: Implement Private NAT Gateways (Bidirectional NAT) or utilize AWS PrivateLink / Azure Private Endpoint architectures to expose microservices via discrete single-host IP endpoints without requiring full VPC route table peering.
2. Kubernetes Pod IP Exhaustion (AWS VPC CNI Tragedy)
In Kubernetes clusters running on AWS EKS using the native AWS VPC CNI plugin, every single Kubernetes Pod is assigned a real, routable IP address directly from the underlying subnet's CIDR block. If an engineer provisions worker node subnets with a /24 prefix (yielding only 251 usable IPs):
- The Failure Mode: A cluster with 8 EC2 instances running 30 pods each immediately demands 240+ IP addresses. During a deployment rollout or Horizontal Pod Autoscaling (HPA) surge, the subnet runs out of IP addresses. The EC2 ENI allocation daemon fails with
FailedCreatePodSandBox: no IP addresses available in subnet, leaving new pods stuck inPendingindefinitely. - The Production Standard: Mandate minimum
/20or/19subnets for Kubernetes worker node pools, or configure Custom Networking in the AWS VPC CNI to attach a dedicated secondary CIDR block (such as100.64.0.0/16CGNAT space) exclusively for Pod IP allocations.
Zero-Downtime Runbook: Expanding an AWS VPC with Secondary CIDR Blocks
If an existing production AWS VPC is running out of IP addresses, you can associate an additional IPv4 CIDR block without deleting or interrupting running resources:
AWS CLI Zero-Downtime Secondary CIDR Allocation
# Step 1: Associate a non-overlapping secondary CIDR block to the existing VPC
aws ec2 associate-vpc-cidr-block \
--vpc-id vpc-0a1b2c3d4e5f67890 \
--cidr-block 100.64.0.0/16
# Step 2: Create a high-capacity subnet within the new CIDR block
aws ec2 create-subnet \
--vpc-id vpc-0a1b2c3d4e5f67890 \
--cidr-block 100.64.10.0/22 \
--availability-zone us-east-1a \
--tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=eks-pod-subnet-1a}]'
# Step 3: Associate the new subnet with the existing private route table
aws ec2 associate-route-table \
--route-table-id rtb-0987654321fedcba0 \
--subnet-id subnet-0123456789abcdef0
IPv6 Subnetting Architecture & Dual-Stack Cloud Migration
While IPv4 utilizes 32-bit addresses yielding 4.29 billion theoretical endpoints, IPv6 (RFC 8200) utilizes 128-bit hexadecimal addressing, providing \(2^{128}\) (approximately \(3.4 \times 10^{38}\)) unique network addresses. In enterprise cloud deployments, understanding IPv6 subnetting boundaries is critical as hyper-scalers (including AWS and Cloudflare) now levy dedicated hourly charges for idle and active IPv4 addresses.
| IPv6 Prefix Length | Address Allocation Block | Assignable Host Capacities | Standard Architecture Assignment |
|---|---|---|---|
/32 |
Regional Internet Registry (RIR) to ISP | \(2^{96}\) subnets | Global Tier-1 ISPs, Telco transit providers |
/48 |
ISP to Enterprise Organization | 65,536 /64 subnets |
Enterprise corporate campus, primary Cloud VPC root allocation |
/56 |
ISP to Small Business / Branch | 256 /64 subnets |
Branch offices, small cloud application boundaries |
/64 |
Standard Single Subnet | \(18.4 \times 10^{18}\) host addresses | Universal Subnet Size: Required for SLAAC (Stateless Address Autoconfiguration) |
/128 |
Single Host Endpoint | 1 address | Loopback (::1/128), point-to-point server host routes |
The /64 Golden Rule in IPv6 Architecture
Unlike IPv4 where subnets are aggressively sized to conserve addresses (e.g., /28 or /30), every single IPv6 local subnet is universally sized as a /64. The IEEE EUI-64 standard and SLAAC router advertisements strictly require the 64-bit boundary to synthesize unique interface identifiers from hardware MAC addresses without requiring stateful DHCP servers.
Step-by-Step Subnetting Scenario: Dividing a /24 into 4 Isolated Microservices
When provisioning a standard 192.168.1.0/24 network for multi-tier microservice isolation, network architects borrow 2 host bits (\(2^2 = 4\) subnets), transitioning the prefix from /24 to /26 (Netmask 255.255.255.192):
- Subnet 1 (Public DMZ / Ingress NGINX):
192.168.1.0/26(Usable:192.168.1.1–192.168.1.62, Broadcast:.63) - Subnet 2 (Application Core API Nodes):
192.168.1.64/26(Usable:192.168.1.65–192.168.1.126, Broadcast:.127) - Subnet 3 (Transactional Database Cluster):
192.168.1.128/26(Usable:192.168.1.129–192.168.1.190, Broadcast:.191) - Subnet 4 (Internal Redis & Kafka Telemetry):
192.168.1.192/26(Usable:192.168.1.193–192.168.1.254, Broadcast:.255)
Frequently Asked Questions About CIDR & Subnetting (PAA)
/24) indicating the exact count of contiguous 1-bits in the network mask. A subnet mask is the 32-bit dotted-decimal representation of those same bits (e.g., 255.255.255.0). Both convey identical mathematical routing boundaries./31 point-to-point links where both addresses can be assigned as host endpoints.10.0.0.0/8 (10.0.0.0 to 10.255.255.255, 16.7M IPs), 172.16.0.0/12 (172.16.0.0 to 172.31.255.255, 1.04M IPs), and 192.168.0.0/16 (192.168.0.0 to 192.168.255.255, 65,536 IPs). These addresses are dropped by public Internet edge routers.255.255.255.255 - SubnetMask). For example, a /24 subnet mask of 255.255.255.0 has a wildcard mask of 0.0.0.255. Wildcard masks are widely used in Cisco IOS Access Control Lists (ACLs) and OSPF routing protocols where 0 means "match exact bit" and 1 means "ignore bit".