Subnet Calculator

Calculate subnet mask, network address, broadcast address, and usable host range from an IP address and CIDR prefix.

About the Subnet Calculator

Subnetting divides a larger network into smaller, more manageable segments. Each subnet has a network address, a broadcast address, and a range of usable host addresses. The subnet mask (or CIDR prefix length) determines how many hosts each subnet can accommodate.

This calculator takes a CIDR prefix length and computes the subnet mask, number of total and usable addresses, network address, and broadcast address. It is an essential tool for network engineers planning IP address allocation, VPC design, and firewall rules.

Understanding subnetting is fundamental to cloud networking. Every VPC, security group, and load balancer configuration requires accurate subnet calculations. Mistakes in subnet sizing lead to address exhaustion, routing conflicts, and security vulnerabilities.

By calculating this metric accurately, DevOps and engineering professionals gain actionable insights that drive system reliability, scalability, and operational excellence across environments. Understanding this metric in precise terms allows technology leaders to make evidence-based decisions about scaling, architecture, and infrastructure investment priorities for their organizations.

Why Use This Subnet Calculator?

Accurate subnet calculations prevent IP address conflicts, ensure proper network segmentation, and are required for VPC design, firewall rules, and security group configuration. Precise quantification supports capacity planning and performance budgeting, ensuring infrastructure investments are right-sized for both current workloads and projected future growth. Data-driven tracking enables evidence-based infrastructure decisions, reducing the risk of over-provisioning costs or under-provisioning that leads to performance bottlenecks.

How to Use This Calculator

  1. Enter the CIDR prefix length (e.g., 24 for a /24 network).
  2. Review the subnet mask, total addresses, and usable host count.
  3. Use the results to plan IP allocation for your network.
  4. Adjust the prefix to find the right subnet size for your needs.

Formula

Total Addresses = 2^(32 − prefix) Usable Hosts = Total − 2 (network and broadcast) Subnet Mask = 32 bits with first `prefix` bits set to 1 Host Bits = 32 − prefix

Example Calculation

Result: /24: 256 total, 254 usable hosts, mask 255.255.255.0

A /24 network has 32 − 24 = 8 host bits. Total addresses: 2^8 = 256. Usable hosts: 256 − 2 = 254. Subnet mask: 11111111.11111111.11111111.00000000 = 255.255.255.0.

Tips & Best Practices

Subnet Sizing for Cloud Networks

Cloud VPC design requires careful subnet planning. Under-sized subnets run out of addresses as services scale. Over-sized subnets waste address space and reduce segmentation options. Plan for 3–5 years of growth when choosing subnet sizes.

Common Subnet Sizes

/24 (254 hosts) is the workhorse for most application subnets. /20 (4,094 hosts) suits large Kubernetes clusters or auto-scaling groups. /28 (14 hosts) works for load balancers, NAT gateways, and management subnets. /16 (65,534 hosts) is typical for VPC-level allocation.

Subnet Security and Segmentation

Subnets are a primary network security boundary. Place different security tiers (public, private, data) in separate subnets with security groups and NACLs controlling traffic between them. Never mix public-facing and internal resources in the same subnet.

Frequently Asked Questions

What is a CIDR prefix?

CIDR (Classless Inter-Domain Routing) notation uses a slash followed by the number of network bits. /24 means the first 24 bits are the network portion, leaving 8 bits for hosts. Larger prefix = smaller subnet. /32 is a single host.

Why are 2 addresses unusable?

The first address (all host bits 0) is the network address, used to identify the subnet. The last address (all host bits 1) is the broadcast address. Neither can be assigned to hosts. So a /24 has 254 usable addresses, not 256.

Which subnet size should I use for a VPC?

Start with /16 for the VPC (65,534 hosts), then divide into smaller subnets: /24 for application tiers, /28 for load balancers, /20 for large workloads. AWS recommends /16 VPCs with /24 subnets across availability zones.

What about IPv6 subnets?

IPv6 uses /64 as the standard subnet size (2^64 addresses). This is vastly larger than any IPv4 subnet. IPv6 subnetting focuses on /48 or /56 allocations to sites, with /64 at the LAN level.

Can subnets overlap?

No. Overlapping subnets cause routing conflicts. Before creating a subnet, verify it doesn't overlap with existing allocations. Cloud VPCs enforce non-overlapping subnets within the same VPC. VPC peering also requires non-overlapping ranges.

What is a /31 or /32 subnet?

A /32 is a single host (used for loopback or host routes). A /31 has 2 addresses and is used for point-to-point links (RFC 3021) where broadcast isn't needed. Both are common in cloud and ISP networking.

Related Pages