Amazon VPC Basics: Your Private Network in AWS, CIDR, Subnets, Route Tables and Internet Gateway

AWS Technical Essentials 55 min min read Updated: Nov 17, 2026 Beginner
Amazon VPC Basics: Your Private Network in AWS, CIDR, Subnets, Route Tables and Internet Gateway
Beginner Topic 1 of 3

What Is a VPC?

A Virtual Private Cloud (VPC) is your own private network inside AWS. You decide the IP address range, the sub-networks, and how traffic comes in and out. Other customers cannot see inside your VPC.

  • A VPC lives in one Region and spans all AZs of that Region
  • Every account gets a default VPC in each Region so beginners can launch servers quickly
  • For real projects you create a custom VPC

IP Addresses and CIDR in Simple Words

Every device on a network has an IP address, like 10.0.1.25. A CIDR block describes a range of addresses, written like 10.0.0.0/16.

CIDRNumber of addressesTypical use
10.0.0.0/1665,536Whole VPC
10.0.1.0/24256One subnet
10.0.1.0/2816Very small subnet
  • The number after / says how many bits are fixed. Smaller number = bigger network
  • VPC size can be between /16 and /28
  • AWS reserves 5 addresses in every subnet, so a /24 has 251 usable addresses
  • Use private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
  • Pick ranges that do not overlap with other networks you may connect later

Subnets

  • A subnet is a slice of the VPC in one Availability Zone
  • Public subnet: has a route to an Internet Gateway, so resources can have public internet access
  • Private subnet: no direct route to the internet. Good for databases and app servers
  • Spread subnets across at least two AZs for high availability

Route Tables

A route table is a set of rules that tells network traffic where to go. Every subnet is linked to one route table.

DestinationTargetMeaning
10.0.0.0/16localTraffic inside the VPC stays inside (always present)
0.0.0.0/0igw-xxxxEverything else goes to the Internet Gateway (this makes a subnet public)
0.0.0.0/0nat-xxxxEverything else goes through a NAT gateway (private subnet outbound only)

Internet Gateway (IGW)

  • A horizontally scaled, highly available gateway between your VPC and the internet. Free to use
  • Attach one IGW to the VPC, add a route 0.0.0.0/0 → IGW to the public subnet's route table, and give instances public IPs
  • All three are needed: IGW attached + route + public IP

A Simple Three-Tier Layout

text VPC 10.0.0.0/16 (ap-south-1) ├─ Public subnet 10.0.1.0/24 (AZ a) Load balancer, NAT gateway route 0.0.0.0/0 → Internet Gateway ├─ Public subnet 10.0.2.0/24 (AZ b) ├─ Private subnet 10.0.11.0/24 (AZ a) Application servers route 0.0.0.0/0 → NAT gateway ├─ Private subnet 10.0.12.0/24 (AZ b) ├─ Private subnet 10.0.21.0/24 (AZ a) Database (no internet route) └─ Private subnet 10.0.22.0/24 (AZ b)

Build a VPC With the CLI

bash VPC=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text) aws ec2 create-tags --resources $VPC --tags Key=Name,Value=demo-vpc aws ec2 modify-vpc-attribute --vpc-id $VPC --enable-dns-hostnames PUB=$(aws ec2 create-subnet --vpc-id $VPC --cidr-block 10.0.1.0/24 --availability-zone ap-south-1a --query Subnet.SubnetId --output text) PRIV=$(aws ec2 create-subnet --vpc-id $VPC --cidr-block 10.0.11.0/24 --availability-zone ap-south-1a --query Subnet.SubnetId --output text) aws ec2 modify-subnet-attribute --subnet-id $PUB --map-public-ip-on-launch IGW=$(aws ec2 create-internet-gateway --query InternetGateway.InternetGatewayId --output text) aws ec2 attach-internet-gateway --internet-gateway-id $IGW --vpc-id $VPC RT=$(aws ec2 create-route-table --vpc-id $VPC --query RouteTable.RouteTableId --output text) aws ec2 create-route --route-table-id $RT --destination-cidr-block 0.0.0.0/0 --gateway-id $IGW aws ec2 associate-route-table --route-table-id $RT --subnet-id $PUB
  • The console option Create VPC → VPC and more builds all of this with a wizard
  • Delete the demo VPC after practice (delete instances and NAT gateways first)

Default VPC vs Custom VPC

Default VPCCustom VPC
Created byAWS automaticallyYou
CIDR172.31.0.0/16Your choice
SubnetsOne public subnet per AZYour design
Best forQuick testsReal applications

Common Mistakes

  • Instance in a public subnet but no public IP or no route to IGW
  • Overlapping CIDRs that block future connections
  • Only one AZ used
  • Putting databases in public subnets

Practice

  1. Look at your default VPC: subnets, route table and internet gateway
  2. Create a custom VPC with a public and a private subnet using the wizard
  3. Launch an instance in the public subnet and confirm you can reach it
  4. Launch one in the private subnet and confirm it has no public IP
  5. Calculate how many usable addresses a /26 has

Conclusion

A VPC is your private network. Plan a CIDR range, split it into public and private subnets across AZs, use route tables to control traffic and attach an Internet Gateway to make a subnet public.

Quick Summary: VPC; CIDR; subnets; route tables; IGW; layout; CLI; default vs custom; mistakes.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators