Subnet Calculation and Planning Tools for Cloud Teams

Subnet planning tools compared: CIDR calculators, Python ipaddress, Terraform cidrsubnet and VPC IPAM, plus AWS, Azure and GCP reserved IPs.

Jul 31, 2025 - 19:15
Nov 12, 2026 - 06:13
 0  35
Subnet Calculation and Planning Tools for Cloud Teams

Subnet calculation and planning tools range from simple CIDR calculators to code and managed services. For quick checks, an online calculator or Python's ipaddress module is enough. For cloud networks you will rebuild, use Terraform's cidrsubnet functions so the plan lives in code. For many accounts, a managed IP address manager such as Amazon VPC IPAM tracks allocations and overlaps.

This guide groups the tools by job, shows working examples, and lists the cloud-specific rules (such as reserved addresses) that a generic calculator will not know. It belongs to our networking fundamentals cluster; the pillar post on the OSI model covers the layers underneath. Cloud limits were checked against AWS, Microsoft and Google documentation in November 2026.

Key takeaways

  • No single tool covers everything. Use a calculator to learn and check, a script or IaC function to generate plans repeatably, and an IP address manager when many teams share address space.
  • Python's standard ipaddress module can split networks, count addresses, list hosts and detect overlaps without installing anything.
  • Terraform's cidrsubnet, cidrsubnets and cidrhost functions compute subnets inside your infrastructure code.
  • Cloud providers reserve addresses in every subnet: five in AWS and Azure, four in a Google Cloud subnet's primary range. Generic calculators show one or two fewer usable hosts than you will lose.
  • Subnet size limits differ: AWS IPv4 subnets range from /28 to /16; Azure supports /29 down to /2; Google Cloud's smallest range is /29.
  • Amazon VPC IPAM helps plan, track and monitor IP space across accounts and can allocate CIDRs to VPCs by rule.

What subnet planning actually involves

Subnetting divides an address block into smaller networks. Planning is the harder part: deciding how big the overall block should be, how to divide it across environments, regions and availability zones, how much room to leave for growth, and how to avoid overlaps with on-premises networks, partners and other clouds you may need to connect to later.

Mistakes are expensive because they are hard to undo. A VPC that is too small, or that overlaps with the corporate network, often cannot be fixed without rebuilding workloads. Our post on the consequences of poor IP address management covers what goes wrong. The tools below exist to catch those mistakes early.

Before using any tool, be clear on the notation. CIDR writes a network as an address plus a prefix length, such as 10.0.0.0/24. The prefix says how many leading bits identify the network; the remaining bits identify hosts. A /24 has 8 host bits, so 256 addresses. For a refresher, see what CIDR notation is and how to calculate subnets for a Class C range.

Types of subnet tools

Tool typeExamplesBest forLimits
Online or desktop CIDR calculatorsAny "subnet calculator" or "CIDR calculator"Learning, quick checks, one-off answersNo record of decisions; usually unaware of cloud reservations
Scripting librariesPython ipaddressRepeatable calculations, validation in CI, bulk checksYou write and maintain the script
IaC functionsTerraform cidrsubnet, cidrsubnets, cidrhostPlans that are created together with the networkOnly covers what that codebase manages
Managed IP address managersAmazon VPC IPAMMany accounts and teams sharing address spaceScoped to one provider's resources
Spreadsheets and documentsA shared allocation registerSmall estates, recording intentDrift from reality, no validation

CIDR calculators

A calculator takes a network and prefix and shows the network address, broadcast address, host range, mask and number of addresses. Many also split a block into equal subnets. AWS's own VPC documentation points users to such tools, suggesting a search for "subnet calculator" or "CIDR calculator" and noting that the network engineering group can help choose blocks.

Calculators are ideal while learning, because you can see immediately how changing the prefix changes the host count. Their weakness is that they assume classic rules: one network address and one broadcast address unavailable. Cloud subnets lose more, as the next section explains, so always subtract the provider's reservation from the calculator's host count.

Cloud-specific rules a calculator will miss

Each major provider reserves addresses in every subnet and sets its own size limits. These come straight from the providers' documentation:

ProviderReserved per IPv4 subnetWhich addressesIPv4 subnet size limits
AWS VPC5Network address, VPC router (+1), DNS (+2), future use (+3), last address/28 to /16
Azure Virtual Network5First four (network, default gateway, two for Azure DNS) and the last/29 to /2
Google Cloud VPC4 in the primary rangeNetwork, default gateway, second-to-last, broadcastSmallest is /29 (8 addresses)

A few related details are worth knowing. In AWS, if you bring your own IPv4 range with BYOIP, you can use every address in it, including the first and last. AWS also canonicalises subnet blocks: ask for 100.68.0.18/18 and it creates 100.68.0.0/18. AWS IPv6 subnets range from /44 to /64 in steps of /4, and Azure IPv6 subnets must be exactly /64. In Google Cloud, secondary ranges have no reserved addresses, and you can expand a subnet's primary range later but cannot shrink or replace it. That last point makes Google Cloud more forgiving of a subnet that starts too small; in AWS and Azure the safer habit is to size generously from the start.

So a /28 in AWS has 16 addresses but only 11 usable for resources. A calculator that reports 14 usable hosts is correct for a traditional LAN and wrong for a VPC.

Python's ipaddress module

When you need the same calculation more than once, a script beats a web page. Python's standard library includes the ipaddress module, so there is nothing to install. The examples below use only functions and attributes documented in the Python reference.

import ipaddress

vpc = ipaddress.ip_network("10.20.0.0/16")

# Split the VPC into /20 subnets
subnets = list(vpc.subnets(new_prefix=20))
print(len(subnets))            # 16
print(subnets[0], subnets[1])  # 10.20.0.0/20 10.20.16.0/20

# Count addresses and usable hosts (classic rules)
s = ipaddress.ip_network("10.20.0.0/28")
print(s.num_addresses)         # 16
print(len(list(s.hosts())))    # 14 (excludes network and broadcast)

# Cloud-aware usable count for AWS or Azure (5 reserved)
print(s.num_addresses - 5)     # 11

# Detect overlap with an on-premises range
onprem = ipaddress.ip_network("10.20.128.0/17")
print(vpc.overlaps(onprem))    # True

The subnets() method takes either prefixlen_diff or new_prefix, but not both, and raises an error if the new prefix is shorter than the original. The hosts() method excludes the network and broadcast addresses except for /31 and /32 networks. The is_private attribute tells you whether an address is in non-globally-reachable space, which is handy for validating input. A short script like this can run in CI to reject a pull request whose new subnet overlaps an existing one.

Terraform CIDR functions

If your network is built with Terraform, compute the subnets in the same code. That way the plan and the network can never disagree. The cidrsubnet(prefix, newbits, netnum) function adds newbits to the prefix length and picks subnet number netnum. HashiCorp's examples include cidrsubnet("10.1.2.0/24", 4, 15), which returns 10.1.2.240/28.

locals {
  vpc_cidr = "10.20.0.0/16"
  azs      = ["ap-south-1a", "ap-south-1b", "ap-south-1c"]
}

# One /20 private subnet per AZ: 10.20.0.0/20, 10.20.16.0/20, 10.20.32.0/20
resource "aws_subnet" "private" {
  count             = length(local.azs)
  vpc_id            = aws_vpc.main.id
  availability_zone = local.azs[count.index]
  cidr_block        = cidrsubnet(local.vpc_cidr, 4, count.index)
}

Two related functions help as well. cidrsubnets allocates several consecutive subnets in one call and numbers them automatically. cidrhost returns a single host address within a prefix; cidrhost("10.1.2.240/28", 1) returns 10.1.2.241. Changing a netnum later changes the subnet and usually forces replacement, so pick the numbering scheme once and leave gaps for growth. Our guide to designing public and private subnets in an AWS VPC shows how these subnets fit into a full layout.

Managed IP address management: Amazon VPC IPAM

Once several teams or dozens of accounts create VPCs, the hard problem is no longer arithmetic. It is coordination: who owns which range, which ranges are free, and whether a new VPC will clash with an existing one. Amazon VPC IP Address Manager is AWS's service for that. Its documentation lists what it does: organise IP space into routing and security domains, monitor space in use against business rules, show the history of IP assignments across the organisation, automatically allocate CIDRs to VPCs according to rules, help troubleshoot connectivity, share BYOIP ranges across regions and accounts, and provision contiguous Amazon-provided IPv6 blocks into pools.

In practice teams create a top-level pool for the organisation, regional pools beneath it, and environment pools beneath those. VPC creation then requests a CIDR from the right pool instead of a person picking one. Azure and Google Cloud have their own approaches; check each provider's documentation before planning a multi-cloud scheme.

A planning workflow that uses the tools together

  1. Choose the top-level range. Use private space from RFC 1918: 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Check it against on-premises, VPN and partner ranges before anything else.
  2. Divide by hierarchy. Split the top range by region, then environment, then VPC. Write the scheme down once, in a document or IPAM pools.
  3. Size subnets for real counts. Estimate peak addresses per subnet, including load balancers, container tasks that get their own IP and growth. Subtract the provider's reserved addresses, then round up to the next prefix.
  4. Generate in code. Use cidrsubnet or an equivalent so subnets are derived from the plan rather than typed by hand.
  5. Validate automatically. Run a script in CI that checks for overlaps and that every subnet sits inside its parent range.
  6. Track allocations. Record what was allocated and to whom, in IPAM or a shared register, and review it periodically.

The business case for doing this carefully is covered in the business benefits of proper subnet planning.

A worked sizing example

Suppose a team is building a new production VPC in one AWS region with three availability zones. Each zone needs a public subnet for load balancers and NAT gateways, a private subnet for application containers, and a private subnet for databases. The team expects up to 900 container tasks at peak, each with its own IP address, spread evenly across the three zones.

Start with the busiest tier. Three hundred tasks per zone, plus room to roughly double, means about 600 addresses per application subnet. A /23 has 512 addresses, which is too small. A /22 has 1,024, minus five reserved by AWS, leaving 1,019. That fits with headroom, so the application tier gets a /22 per zone.

The public tier needs far fewer addresses: load balancer nodes, NAT gateways and perhaps a bastion host. A /26 per zone gives 64 addresses, 59 usable, which is generous. The database tier might hold a handful of instances and replicas per zone; a /26 works there too, and keeping it the same size as the public tier makes the layout easy to read.

Add those up: three /22 blocks use 3,072 addresses, and six /26 blocks use 384. A /20 (4,096 addresses) would hold all of it but leaves little room for a fourth zone or new tiers. A /19 or /18 for the VPC gives space to grow without renumbering. Before committing, the team runs the overlap check from the Python example against the corporate network and every other VPC it may need to peer with, and records the allocation in its IPAM pool or register.

In Terraform, the /22 application subnets can be generated with cidrsubnet(var.vpc_cidr, 4, n) from a /18 VPC, and the /26 subnets from a dedicated /22 carved out for small tiers. Writing the plan down this way means the arithmetic is checked every time the code runs, and anyone reading the module can see how the space was divided.

Choosing a tool by team size

A single engineer running one or two VPCs rarely needs more than a calculator and a short note in the repository explaining the scheme. Once the network is built with infrastructure code, moving the calculation into cidrsubnet costs almost nothing and removes typing errors.

A platform team serving several application teams benefits from a validation script in CI, so a pull request that adds an overlapping subnet fails before review. At this stage a shared allocation register also becomes important, even if it starts as a simple file in Git.

An organisation with many accounts, regions and connected networks needs a managed IP address manager. The value there is less about calculation and more about ownership, history and automatic allocation, which spreadsheets cannot provide reliably.

Common mistakes the tools help you avoid

  • Using the classic "hosts = 2^n minus 2" rule in the cloud and running out of addresses earlier than expected.
  • Picking a small VPC block such as a /24 for a workload that later adds container tasks, each needing its own IP address.
  • Reusing the same 10.0.0.0/16 in every account, then discovering the VPCs cannot be peered or routed together.
  • Typing subnet ranges by hand in many places, so one typo creates an overlap.
  • Keeping the allocation spreadsheet in someone's personal drive, where it slowly drifts away from what is deployed.

Networking questions like these come up often in cloud and Linux administration interviews. Our DevOps training in Kharadi, Pune and live online includes VPC design labs where you size and build subnets with Terraform.

Frequently asked questions

What is the best free tool for subnet calculation?

For quick checks, any CIDR calculator works. For repeatable work, Python's built-in ipaddress module and Terraform's cidrsubnet functions are free and keep the calculation in code.

How many IP addresses does AWS reserve in a subnet?

Five: the network address, the VPC router, the DNS address, one reserved for future use, and the last address. A /28 subnet therefore has 11 usable addresses.

Does Azure reserve the same addresses as AWS?

Azure also reserves five per subnet: the first four and the last. The smallest supported Azure IPv4 subnet is /29 and the largest is /2.

How many addresses does Google Cloud reserve?

Four in a subnet's primary IPv4 range: network, default gateway, second-to-last and broadcast. Secondary ranges have no reserved addresses.

What does Terraform's cidrsubnet function do?

cidrsubnet(prefix, newbits, netnum) extends the prefix by newbits and returns subnet number netnum. For example, cidrsubnet("10.1.2.0/24", 4, 15) returns 10.1.2.240/28.

When do I need an IP address manager like VPC IPAM?

When many accounts or teams create networks and you need to track ownership, prevent overlaps and allocate CIDRs by rule instead of by hand.

Can I resize a subnet later?

Google Cloud lets you expand a subnet's primary range but not shrink or replace it. In AWS and Azure, plan sizes carefully up front, since changing a subnet's range usually means recreating it.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.