VPCs, subnets and address planning

Beginner · 10 min

Design an Amazon VPC: CIDR blocks, subnets per Availability Zone, the five reserved addresses, default VPCs, IPv6 and planning so networks can connect.

Before thisRegions, endpoints, ARNs and service scope

Tiny Technical Tutorials · 10 min

VPCs, subnets and address planning

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Tiny Technical TutorialsReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A VPC is your private network in one Region. A subnet is a slice of its address range in exactly one Availability Zone.
  • VPC and subnet IPv4 blocks range from /16 to /28, and AWS reserves five addresses in every subnet.
  • A subnet is public or private because of its route table, not because of any setting called public.
  • Choose ranges that do not overlap with other VPCs or your offices. Overlap prevents routing between them, and fixing it means rebuilding.
  • Give each zone the same tiers, size private subnets generously, and leave space unallocated.
  • You can add secondary CIDR blocks to a VPC, but you cannot resize a block or a subnet in place.

Your own network inside AWS

Put a database on a shared network and anything on that network can try to reach it. What you want is your own network, where you decide the addresses and what connects to what.

That is a VPC, a virtual private cloud: an isolated network in one Region. Inside it you create subnets, and inside subnets go the things with network interfaces. If subnets and CIDR notation are new, start there.

Think of the VPC as a plot of land and subnets as the buildings on it. Each building stands in one place, an Availability Zone. A road plan, the route tables, decides where each can go.

The rules of addressing

  • An IPv4 block for a VPC or subnet is between /16 (65,536 addresses) and /28 (16).
  • A subnet lives in one zone and takes part of the VPC’s range. Subnets cannot overlap.
  • Every subnet loses five addresses. In 10.0.0.0/24: .0 is the network address, .1 the router, .2 reserved alongside the DNS server, .3 reserved for future use, and .255 reserved since there is no broadcast.
  • You can add secondary blocks to a VPC (5 blocks by default, raisable to 50). You can’t grow or shrink a block or subnet.

Use private ranges: 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Avoid 172.17.0.0/16, which Docker and some AWS services use.

Plan before you create

Changing addresses later means moving everything, so spend ten minutes now. The usual shape is the same set of tiers in each zone:

  • public: load balancers and NAT gateways, small;
  • private: applications, containers and functions, large;
  • data: databases and caches, small and tightly restricted.

A few lines of Python’s ipaddress module will carve a /16 for you:

a  private  10.20.0.0/19      8187 usable
a  public   10.20.32.0/22     1019 usable
a  data     10.20.36.0/22     1019 usable
b  private  10.20.64.0/19     8187 usable
b  public   10.20.96.0/22     1019 usable
...
c  data     10.20.164.0/22    1019 usable
unallocated /18: 10.20.192.0/18

A whole quarter is left spare for a fourth zone or a tier you haven’t thought of.

Private subnets are large on purpose. Addresses go faster than instance counts suggest, especially with containers: on EKS each Pod takes a VPC address, as EKS networking explains.

Across the organization, give every VPC a unique range: per Region, per environment, per account. Keep a register. Amazon VPC IPAM is the managed register that hands out non-overlapping blocks, and it becomes worthwhile with many accounts.

Creating it

aws ec2 create-vpc --cidr-block 10.20.0.0/16
aws ec2 create-subnet --vpc-id vpc-... --cidr-block 10.20.0.0/19 --availability-zone eu-west-1a

The response shows the zone ID (euw1-az3) and AvailableIpAddressCount, 8187 for this /19 and 11 for a /28. A second subnet overlapping the first is refused with InvalidSubnet.Conflict.

A new VPC’s route table has a single entry, 10.20.0.0/16 -> local. Everything inside can route to everything inside. Nothing can reach outside. A subnet becomes public when you add a route to an internet gateway, which is the next lesson.

The default VPC

Each Region comes with a default VPC (172.31.0.0/16) with a public subnet in each zone and an internet gateway, so that launching an instance just works. That convenience is the problem in production: things land on public subnets by accident, and every account’s default VPC has the same range. Use your own.

IPv6 and account-wide brakes

You can add IPv6 to a VPC, typically a /56 with /64 subnets, which ends address scarcity. IPv6 addresses are globally unique, so privacy comes from routing and firewall rules rather than from private ranges. Dual-stack or IPv6-only subnets are both possible.

VPC Block Public Access is a Region-wide account setting that overrides routing to block internet traffic, in both directions or inbound only, with explicit exclusions. It is a good safety net for accounts that should never be exposed.

About the video

The embed is Tiny Technical Tutorials’ “VPC Basics”, February 2022, 10 minutes. Its chapters cover why you need a VPC, public and private subnets with routes and an internet gateway, Regions and zones, CIDR notation, internet and NAT gateways, and network ACLs and security groups. It is a broad first look; the next few lessons take each piece apart. It predates newer features such as Block Public Access. I judged it from chapters and description, since transcripts couldn’t be fetched.

What was run: the address plan is from a Python script run locally. The VPC and subnet calls ran against moto, a local emulator. moto also accepted a /29 subnet, which AWS’s documented limits do not allow. Sizes, reserved addresses, quotas and features are from AWS documentation, checked in November 2026.

Where this fits

You have address space and no way out. Next: route tables, internet gateways and NAT.

Check yourself

  1. 01How many addresses can you use in a /28 subnet?

    Eleven. A /28 has 16 addresses and AWS reserves the first four and the last one.

  2. 02Two teams each built a VPC with 10.0.0.0/16. Now the applications must talk privately. What is the problem?

    Routing needs to know which network an address belongs to, and both claim it, so they cannot be peered. You need renumbering, or a workaround such as PrivateLink that exposes single services.

  3. 03You need one application tier in three zones. How many subnets?

    Three, one per zone, because a subnet cannot span Availability Zones.

  4. 04A subnet runs out of addresses although only a few instances are in it. What else might be using them?

    Anything with a network interface: load balancers, NAT gateways, interface endpoints, Lambda attachments, container tasks and Pods.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark