Skip to Content
Cloud Engineering Academy
2. AWS Networking & Infrastructure

CIDR planning: an IP plan that never overlaps

Plan non-overlapping address ranges for dev, test, prod, two data centres and a partner, size subnets for AWS, and check the plan with a tested C# library (Lab 2.1).

beginnerโฑ 1 h 15 min๐ŸŸข FreeSAA-C03SOA-C03

Assumes: .NET 10 LTS ยท CDK v2 (Amazon.CDK.Lib 2.277.0) ยท Terraform 1.14 / AWS provider v6 ยท Region us-east-1. Verified against official sources on 2026-11-17.

Learning objectives

By the end of this lesson you can:

  • Explain why overlapping address ranges are the most expensive networking mistake to undo.
  • Build an organisation-level IP plan with room for growth: data centres, AWS environments, remote access and subsidiaries.
  • Size subnets for AWS (five reserved addresses, AZ growth, container and Lambda ENIs) and keep each tier on an aligned block.
  • Express the plan in Terraform (cidrsubnet), CDK (IpAddresses.Cidr + CidrMask) and check it with the lab's Harbourline.Networking.CidrPlanner library.
  • Describe what Amazon VPC IP Address Manager (IPAM) adds in production.

Prerequisites

Why this matters in banking

Banks connect everything: two or more data centres, many AWS accounts, card schemes, payment networks, Open Banking partners, acquired companies and staff VPNs. Routing only works if every address is unique across all of them. When two networks overlap, packets for "10.20.5.7" cannot know which network you mean.

Harbourline Bank learned this with an Open Banking partner, Northgate Payments (fictional). Northgate's integration VPC uses 10.20.0.0/16 โ€” the same range as Harbourline's dev VPC. A VPC peering request fails immediately, a Transit Gateway attachment would black-hole traffic, and a VPN cannot route to both. The fix is not cheap: either re-address a live network, or put a translation layer (PrivateLink or private NAT) in between. A one-page IP plan, agreed before the first VPC, prevents most of this.

The idea in plain language

An IP plan is a register of who owns which address range, written before anyone builds anything. You start from a large private block, give each big area (data centre, AWS, VPN pool) a slice, then give each environment and VPC a smaller slice inside its area. Every new request is checked against the register.

Analogy: a city's postcode plan. The council assigns district codes first (EC, WC, N, SW), then each district assigns streets. Two streets never share a postcode, and new estates are planned into empty districts โ€” nobody renumbers Oxford Street after the fact.

The Harbourline register

RangeOwner / use
10.0.0.0/14On-prem London data centre (LDN-DC1, primary)
10.4.0.0/14On-prem Manchester data centre (MAN-DC2, DR)
10.16.0.0/12All of AWS (10.16.0.0 โ€“ 10.31.255.255)
10.16.0.0/16Network hub / shared services (inspection, egress, DNS resolver endpoints)
10.17.0.0/16prod โ€” Payments VPC
10.18.0.0/16prod โ€” Accounts API VPC
10.19.0.0/16test / pre-prod
10.20.0.0/16dev and the learning sandbox (this module's lab VPC)
10.21.0.0/16 โ€“ 10.31.0.0/16Reserved: growth and the EU subsidiary (eu-west-1)
172.16.0.0/16Staff remote-access VPN pool
100.64.0.0/10Never used for workloads (carrier-grade NAT space)

Why these choices:

  • One summarisable AWS block. 10.16.0.0/12 lets the data centres send one route to AWS ("everything in 10.16/12 goes over Direct Connect") instead of one per VPC.
  • Aligned blocks. Each /16 starts on a /16 boundary, each /14 on a /14 boundary, so every range can be written as a single CIDR.
  • Reserved space is part of the plan. Eleven unused /16s cost nothing and save a re-addressing project.
  • The VPN pool sits outside 10/8. Staff home routers often use 192.168.x.x and sometimes 10.0.x.x; keeping the VPN pool in 172.16/16 avoids clashes with on-prem ranges.

Inside a VPC: tiers and AZs

The lab VPC 10.20.0.0/16 uses /20 subnets in two AZs. Each tier gets an aligned /18 block with room for four AZs:

TierBlockAZ aAZ bRoom for
public10.20.0.0/1810.20.0.0/2010.20.16.0/2010.20.32.0/20, 10.20.48.0/20
app (private)10.20.64.0/1810.20.64.0/2010.20.80.0/2010.20.96.0/20, 10.20.112.0/20
data (isolated)10.20.128.0/1810.20.128.0/2010.20.144.0/2010.20.160.0/20, 10.20.176.0/20
spare10.20.192.0/18โ€”โ€”a fourth tier (for example endpoints)

Two benefits of aligned tier blocks:

  1. Adding a third AZ never renumbers anything. 10.20.96.0/20 is waiting.
  2. One rule covers a tier. A NACL or firewall rule "allow from the app tier" can be 10.20.64.0/18 instead of a list.

Sizing rules

  • Subtract five per subnet (AWS reservations): a /24 is 251 usable, a /20 is 4,091.
  • Count ENIs, not servers. Every Fargate task, every Lambda function's Hyperplane ENI, every interface endpoint (one per AZ), every load balancer node and every RDS instance takes an address. EKS with the VPC CNI gives each pod an address โ€” plan /19 or larger for pod subnets, or use a secondary CIDR.
  • Public subnets can be smaller (they only hold load balancers and NAT gateways); this lab keeps them /20 for simplicity.
  • Secondary CIDRs can be added to a VPC later (up to 5 by default, adjustable to 50), but they must come from the plan too, and some ranges cannot be combined (for example, a VPC whose primary block is in 10/8 cannot add a 172.16/12 or 192.168/16 secondary โš  VERIFY the exact restriction table).
  • IPv6 removes scarcity (each subnet is a /64), but you still need an IPv4 plan for anything that talks to on-premises or partners.

What problem this solves (and IPAM)

A spreadsheet works for one team. A bank needs enforcement. Amazon VPC IP Address Manager (IPAM) holds the plan as pools (for example a top-level pool 10.16.0.0/12 with Regional and environment pools under it), lets accounts request a VPC CIDR from a pool instead of typing one, and alerts on overlaps and unmanaged ranges across the whole Organization.

IPAM tierPrice (checked 2026-11-17)What you get
Free TierUSD 0Single account and Region features
Advanced TierUSD 0.00027 per active IP address per hourOrganization-wide pools, allocation rules, compliance monitoring, BYOIP

Advanced Tier for 10,000 active addresses โ‰ˆ 10,000 ร— 0.00027 ร— 730 โ‰ˆ USD 1,971 per month โ€” a real line item, which is why smaller teams start with a register in Git plus an automated overlap check (exactly what the lab library does).

Limits of a plan: it cannot fix partners or acquisitions that already overlap you. For those, use PrivateLink (the consumer sees an address in its own range) or private NAT. See VPC endpoints and PrivateLink.

Microsoft / Azure comparison

You know (Microsoft/Azure)AWS equivalentWhat's different
VNet address space planningVPC CIDR planningSame discipline; VPC blocks are /16โ€“/28
Azure Virtual Network Manager IPAM (preview/GA features)Amazon VPC IPAMIPAM pools can be shared to accounts with AWS RAM
Hub-and-spoke VNet rangesNetwork hub VPC + workload VPCs on Transit GatewaySummarised routes work the same way
Azure reserves 5 addresses per subnetAWS reserves 5 addresses per subnetSame count
Subnet delegation for servicesDedicated subnets for endpoints, EKS podsPlan a spare tier block for them

Architecture

Step-by-step implementation (Lab 2.1 โ€” the IP-planning exercise)

Gather requirements

Harbourline needs: two data centres (each currently using about 150,000 addresses, growth 50%), AWS with dev, test and prod (prod split into Payments and Accounts), a network hub, a staff VPN for 3,000 users, an EU subsidiary in eu-west-1 with its own dev/test/prod, and room for five more VPCs. Partners must not overlap you.

Choose the area blocks

Each data centre needs about 225,000 addresses with growth: a /14 (262,144) fits. AWS needs at least 9 VPCs of /16 now plus growth: a /12 (16 ร— /16) fits with 7 spare. The VPN needs 3,000+: a /20 would do, but a /16 in 172.16/12 keeps it obviously separate.

Fill the worksheet

Copy this table into your notes and fill the right-hand column before you look at the solution.

NeedYour range
LDN-DC1
MAN-DC2
AWS supernet
Network hub
prod Payments
prod Accounts
test
dev
EU subsidiary dev / test / prod
Staff VPN

Split one VPC into tiers

For your dev VPC, choose three tiers and a subnet size. Use aligned tier blocks with room for four AZs.

Check it with code

Clone the lab, run the planner CLI against your VPC, and run --check against the partner range. Then run the unit tests, which encode the rules.

AWS Console instructions

There is nothing to create for the exercise. To see the plan in AWS: Console โ†’ VPC โ†’ IP Address Manager (IPAM) shows IPAM; creating one in Free Tier for a single Region costs nothing, but delete it afterwards to keep the account tidy โš  VERIFY current console labels. When you later create a VPC (VPC โ†’ Create VPC), the IPv4 CIDR block field accepts either manual input or IPAM-allocated IPv4 CIDR block.

AWS CLI

# What ranges are already in use in this Region? (start of any planning exercise)
aws ec2 describe-vpcs --profile learn-sandbox --region us-east-1 `
  --query "Vpcs[].{Vpc:VpcId,Cidrs:CidrBlockAssociationSet[].CidrBlock}" --output json

# Do any existing subnets overlap the range you want to use? (simple filter on the VPC CIDR)
aws ec2 describe-subnets --profile learn-sandbox --region us-east-1 `
  --query "Subnets[?starts_with(CidrBlock, '10.20.')].[SubnetId,CidrBlock,VpcId]" --output table

# Optional, production-style: an IPAM in this Region (Free Tier) with a top-level pool
# aws ec2 create-ipam --operating-regions RegionName=us-east-1 --tier free --profile learn-sandbox --region us-east-1

The starts_with filter is only a rough check (it misses ranges such as 10.16.0.0/12 that contain yours). The C# overlap check below is the reliable one.

Infrastructure as Code

PlannedVpc.cs (excerpt from the lab's SecureVpcStack)
// CDK allocates subnet CIDRs in configuration order, AZ by AZ.
// "Reserved" groups take up address space without creating subnets,
// which keeps every tier on its aligned /18 block.
var vpc = new Vpc(this, "Vpc", new VpcProps
{
    IpAddresses = IpAddresses.Cidr("10.20.0.0/16"),
    MaxAzs = 2,
    NatGateways = 0,
    SubnetConfiguration =
    [
        new SubnetConfiguration { Name = "public",       SubnetType = SubnetType.PUBLIC,           CidrMask = 20 },
        new SubnetConfiguration { Name = "public-spare", SubnetType = SubnetType.PUBLIC,           CidrMask = 20, Reserved = true },
        new SubnetConfiguration { Name = "app",          SubnetType = SubnetType.PRIVATE_ISOLATED, CidrMask = 20 },
        new SubnetConfiguration { Name = "app-spare",    SubnetType = SubnetType.PRIVATE_ISOLATED, CidrMask = 20, Reserved = true },
        new SubnetConfiguration { Name = "data",         SubnetType = SubnetType.PRIVATE_ISOLATED, CidrMask = 20 },
    ],
});

With two AZs this produces public 10.20.0.0/20 and 10.20.16.0/20, reserves .32 and .48, app 10.20.64.0/20 and 10.20.80.0/20, reserves .96 and .112, and data 10.20.128.0/20 and 10.20.144.0/20. A CDK assertion test in the lab compares these CIDRs with the planner library's output, so the two can never drift apart.

Complete code

The lab ships a tested planning library and a CLI: labs/m02-secure-vpc/src/Harbourline.Networking.CidrPlanner and src/Harbourline.Networking.PlanCli. The main types:

TypePurpose
Ipv4CidrStrict parsing (rejects host bits and leading zeros), Contains, Overlaps, Split, Subnet, AwsUsableAddresses
VpcPlanner.Plan(vpc, tiers, azs, subnetPrefix)Aligned tier blocks with room for four AZs; throws if the plan does not fit
OverlapDetector.FindOverlaps(ranges) / Conflicts(proposed, register, allowedParents)Finds every overlapping pair; checks a new range against the register
HarbourlineIpRegister.AllocationsThe register table above, as code

A short program using the library (add a project reference to Harbourline.Networking.CidrPlanner):

Program.cs
using Harbourline.Networking.CidrPlanner;

// 1. Plan the test VPC with three AZs and /22 subnets
var plan = VpcPlanner.Plan(Ipv4Cidr.Parse("10.19.0.0/16"), ["public", "app", "data"], ["us-east-1a", "us-east-1b", "us-east-1c"], 22);
foreach (var s in plan.AllSubnets)
{
    Console.WriteLine($"{s.Tier,-7} {s.AvailabilityZone,-11} {s.Cidr,-15} usable {s.UsableAddresses}");
}

// 2. Check the partner's range against the bank's register
var partner = NamedRange.Of("northgate-payments", "10.20.0.0/16");
var conflicts = OverlapDetector.Conflicts(partner, HarbourlineIpRegister.Allocations, HarbourlineIpRegister.AwsSupernetName);
Console.WriteLine(conflicts.Count == 0 ? "Partner range is safe to route" : $"Conflict: {string.Join(", ", conflicts.Select(c => c.First.Name))}");

Or use the CLI directly:

cd labs/m02-secure-vpc
dotnet run --project src/Harbourline.Networking.PlanCli
dotnet run --project src/Harbourline.Networking.PlanCli -- --vpc 10.19.0.0/16 --prefix 22 --azs us-east-1a,us-east-1b,us-east-1c
dotnet run --project src/Harbourline.Networking.PlanCli -- --check 10.20.0.0/16
dotnet test --solution SecureVpc.slnx

Expected output of the first command:

VPC 10.20.0.0/16 (65,536 addresses)
Tier     Block            AZ           Subnet             Usable
public   10.20.0.0/18     us-east-1a   10.20.0.0/20        4,091
public   10.20.0.0/18     us-east-1b   10.20.16.0/20       4,091
app      10.20.64.0/18    us-east-1a   10.20.64.0/20       4,091
app      10.20.64.0/18    us-east-1b   10.20.80.0/20       4,091
data     10.20.128.0/18   us-east-1a   10.20.128.0/20      4,091
data     10.20.128.0/18   us-east-1b   10.20.144.0/20      4,091
spare    10.20.192.0/18
Subnet overlap check: none
Register check: no conflicts with Harbourline allocations

And --check 10.20.0.0/16 prints CONFLICT: 10.20.0.0/16 overlaps 1 allocated range(s): aws-dev-sandbox with exit code 2 โ€” a pipeline can fail on it.

Code explained line by line

  1. Ipv4Cidr.Parse("10.19.0.0/16") โ€” strict parsing: 10.19.1.0/16 throws with a hint (did you mean 10.19.0.0/16?) instead of silently truncating, because a typo in an IP plan is a production incident later.
  2. VpcPlanner.Plan(vpc, tiers, azs, 22) โ€” the tier block is the subnet prefix minus 2 (/20 here), giving four AZ slots per tier. With a /16 VPC that is 16 tier blocks, so the three tiers fit with 13 spare.
  3. s.UsableAddresses โ€” the subnet size minus AWS's five reserved addresses (1,019 for a /22).
  4. NamedRange.Of("northgate-payments", "10.20.0.0/16") โ€” every range in the register has a human name, so error messages say who you collide with.
  5. OverlapDetector.Conflicts(partner, register, AwsSupernetName) โ€” checks the proposal against every allocation; the allowedParents argument ignores the AWS supernet containing a new VPC (that is intended), but would still flag a partner range overlapping it if you did not list it.
  6. Inside the library, FindOverlaps sorts ranges by start address and stops scanning once a later range starts after the current one ends โ€” the same "sweep" idea used in calendar clash detection.
  7. The tests in tests/Harbourline.Networking.CidrPlanner.Tests cover parsing edge cases, the exact lab plan, "adding an AZ never renumbers", partner conflicts and the bank register itself.

Security considerations

  • The IP register is sensitive: it maps your internal estate. Keep it in a private repository with reviewed changes.
  • Never rely on address ranges as authentication ("anything from 10.0.0.0/8 is trusted"). Ranges are for routing; identity (IAM, mTLS) is for trust.
  • Avoid 100.64.0.0/10 and ranges used by AWS services (for example 172.17.0.0/16 is Docker's default bridge on build agents) โš  VERIFY your tooling's defaults.
  • Changes to the plan affect firewall rules on-premises; route every change through network and security change management.

โš  Learning shortcut โ€” not for production

The lab keeps the register as C# code and checks overlaps in unit tests. In a bank the register lives in Amazon VPC IPAM (or the bank's IPAM product), accounts receive CIDRs by allocation from shared pools, and an automated check runs in the IaC pipeline before any VPC, VPN or partner connection is created.

Banking use case

Harbourline's network team owns an IPAM top-level pool 10.16.0.0/12, split into Regional pools (us-east-1, eu-west-2, eu-west-1) and then environment pools. The Payments team's CDK app asks for "a /16 from the prod-eu-west-2 pool" instead of typing a CIDR. When Northgate Payments' onboarding form arrives with 10.20.0.0/16, the pipeline's overlap check fails, and the architecture decision is made early: expose Harbourline's partner API to Northgate through a PrivateLink endpoint service, which works regardless of overlapping ranges.

Common mistakes

  • Every VPC gets 10.0.0.0/16 (the wizard default) โ†’ no two VPCs can ever be connected โ†’ assign from the plan.
  • Sizing subnets by number of servers โ†’ Lambda, Fargate and EKS exhaust addresses โ†’ count ENIs and pods.
  • Unaligned blocks (10.20.10.0/20 is invalid; 10.20.8.0/21 "works" but breaks summarisation) โ†’ use cidrsubnet or the planner.
  • No reserved space โ†’ the fourth AZ or a new tier forces re-addressing โ†’ reserve slots per tier.
  • Forgetting on-premises and VPN ranges โ†’ AWS plan is tidy but collides with the data centre โ†’ one register for the whole bank.

Troubleshooting

SymptomLikely causeFix
InvalidSubnet.Range when creating a subnetSubnet not inside the VPC CIDR, or host bits setRecalculate with cidrsubnet or the planner
InvalidSubnet.ConflictOverlaps an existing subnet in the VPCList subnets; pick the next free block
VPC peering request fails with overlapping CIDRsThe two VPCs share addressesRe-address one side, or use PrivateLink
InsufficientFreeAddressesInSubnet (Lambda/ECS)Subnet too small for ENIsLarger subnets or a secondary CIDR
Planner throws "only N tier blocks"Subnet prefix too large for the number of tiersUse smaller subnets or fewer tiers

Cost and cleanup

Cost: USD 0. Planning, the CLI and the tests run locally. If you created an IPAM in Free Tier, delete it:

aws ec2 describe-ipams --profile learn-sandbox --region us-east-1 --query "Ipams[].IpamId"
aws ec2 delete-ipam --ipam-id ipam-0123456789abcdef0 --cascade --profile learn-sandbox --region us-east-1
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab --region us-east-1 --profile learn-sandbox --query "ResourceTagMappingList[].ResourceARN"

Exercises

  • ๐ŸŸข Guided: Complete the worksheet, then run the planner CLI for your dev and test VPCs and --check your EU subsidiary ranges.
  • ๐ŸŸก Challenge: Add a fourth tier endpoints with /24 subnets to the dev VPC without changing the existing /20 tiers. (Hint: the spare /18 can be split differently from the others.) Write a unit test for it.
  • ๐Ÿ”ด Live problem: Harbourline acquires a small fintech whose AWS estate uses 10.16.0.0/16, 10.17.0.0/16 and 172.31.0.0/16 (default VPCs). The business wants their customer data API reachable from Harbourline's Payments VPC within a month. Propose two options with trade-offs.

Assignment

Commit docs/ip-plan.md with your filled worksheet, a Mermaid diagram of your plan and the output of PlanCli for two VPCs. Add a CI step (GitHub Actions) that runs dotnet test on the planner so a pull request that breaks the register fails.

Solutions

Knowledge check

Interview questions

  • "How would you plan IP addressing for a bank moving to AWS?" โ€” One register for on-prem, cloud, VPN and partners; a summarisable AWS supernet; per-environment /16s; aligned tier blocks with AZ growth; IPAM pools with allocation rules; automated overlap checks in the pipeline.
  • "A partner overlaps your ranges. What now?" โ€” PrivateLink for service-level access (works with overlaps), or private NAT; re-addressing only if the relationship is long-term and deep.
  • "Why do serverless and container platforms change subnet sizing?" โ€” Each task, pod or function ENI consumes an address; bursts can exhaust small subnets.

Certification practice

Completion checklist

  • I completed the worksheet and compared it with the solution
  • I ran PlanCli for two VPCs and the --check mode
  • I ran the planner unit tests (dotnet test --solution SecureVpc.slnx)
  • I can explain aligned tier blocks and why they help routing and NACLs
  • I deleted any IPAM I created

Key takeaways

  • Overlapping ranges are expensive to fix; plan the whole bank's address space first.
  • Use a summarisable AWS supernet and aligned blocks at every level.
  • Size subnets by ENIs (containers, Lambda, endpoints), and subtract five.
  • Keep the plan in a reviewed register; check every new range automatically.
  • When overlaps are unavoidable, PrivateLink beats re-addressing in the short term.

Further reading

Independent learning resource โ€” not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.

On this page