You own 10.0.0.0/16 for a new VPC and need separate /24 subnets for dev, QA and prod across two AZs. How do you carve it up?
BeginnerScenarioAddressing, CIDR & Routing
Answer
Situation read → Classic subnetting question. /16 gives 256 possible /24s, so space is not the issue; the issue is leaving room to grow and keeping the plan readable.
What I'd do →
- Give each environment a block of the third octet, for example dev
10.0.0.0/20, QA10.0.16.0/20, prod10.0.32.0/20, and leave10.0.48.0onward unallocated - Inside each /20 use /24s per AZ and tier, for example
10.0.32.0/24prod-public-a,10.0.33.0/24prod-public-b,10.0.34.0/24prod-private-a - Write the plan in a table in the repo and codify it in Terraform with
cidrsubnet("10.0.0.0/16", 4, 2) - Check with
ipcalc 10.0.32.0/20that the ranges do not overlap
Why → Aligned blocks summarize cleanly in route tables and security rules (one /20 rule per environment instead of 16 /24 rules), and unallocated space lets you add a region or tier later.
Interview tip → Say you never carve a VPC "as needed" because ad hoc allocation is what produces overlap when you later peer.
More on Addressing, CIDR & Routing
A host is configured as 192.168.1.130/25. What network does it belong to and what is the broadcast address?BeginnerHow many usable IPs does an AWS subnet of /28 have?BeginnerA route table has 10.0.0.0/16 -> local and 10.0.1.0/24 -> vpn-gw. Where does a packet to 10.0.1.5 go?BeginnerA newly built server can ping everything in its subnet but nothing outside. What is the first thing you check?BeginnerYou are picking a private range for a new company network. Which RFC 1918 range do you choose and why?BeginnerA server has two NICs and traffic to 10.20.0.0/16 is leaving through the wrong one. How do you see and fix the route?Beginner