Skip to main content

Fundamental VPC Concepts

What is a VPC?​

A VPC (Virtual Private Cloud) is your virtual private network in AWS. It's an isolated network space where you deploy your AWS resources.

┌─────────────────────────────────────────────────────────────┐
│ AMAZON VPC │
├─────────────────────────────────────────────────────────────┤
│ │
│ "Your virtual datacenter in the cloud" │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ VPC (10.0.0.0/16) │ │
│ │ │ │
│ │ Your private and isolated network space │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Subnet 1 │ │ Subnet 2 │ │ │
│ │ │ 10.0.1.0/24 │ │ 10.0.2.0/24 │ │ │
│ │ │ │ │ │ │ │
│ │ │ ┌─────┐ │ │ ┌─────┐ │ │ │
│ │ │ │ EC2 │ │ │ │ RDS │ │ │ │
│ │ │ └─────┘ │ │ └─────┘ │ │ │
│ │ │ │ │ │ │ │
│ │ └─────────────┘ └─────────────┘ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ Features: │
│ • Isolated from other VPCs and the Internet (by default) │
│ • You control the IP address range │
│ • You define the security rules │
│ • Regional (spans all AZs in the region) │
│ │
└─────────────────────────────────────────────────────────────┘

Analogy: VPC = Office Building​

┌─────────────────────────────────────────────────────────────┐
│ ANALOGY: OFFICE BUILDING │
├─────────────────────────────────────────────────────────────┤
│ │
│ REAL WORLD AWS │
│ ────────── ─── │
│ │
│ 🏢 Building = VPC │
│ (your private space) (your private network) │
│ │
│ 🚪 Floors = Subnets │
│ (internal divisions) (sub-networks) │
│ │
│ 🔐 Reception/Security = Internet Gateway │
│ (controlled entry) (Internet access) │
│ │
│ 📋 Access badge = Security Group │
│ (who can enter where) (firewall rules) │
│ │
│ 🗺️ Evacuation plan = Route Table │
│ (traffic paths) (traffic routing) │
│ │
│ 🏠 Offices = EC2 Instances │
│ (workspaces) (your servers) │
│ │
└─────────────────────────────────────────────────────────────┘

Components of a VPC​

Overview​

┌─────────────────────────────────────────────────────────────┐
│ VPC COMPONENTS │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ VPC │ │
│ │ (container) │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ SUBNET │ │ SUBNET │ ← Subnets │ │
│ │ │ (public) │ │ (private) │ │ │
│ │ └──────┬──────┘ └──────┬──────┘ │ │
│ │ │ │ │ │
│ │ └────────┬───────┘ │ │
│ │ │ │ │
│ │ ┌────────┴────────┐ │ │
│ │ │ ROUTE TABLE │ ← Where traffic goes │ │
│ │ └────────┬────────┘ │ │
│ │ │ │ │
│ │ ┌───────────────┼───────────────┐ │ │
│ │ │ │ │ │ │
│ │ ▼ ▼ ▼ │ │
│ │ ┌─────┐ ┌─────────┐ ┌──────────┐ │ │
│ │ │ IGW │ │ NAT │ │ VPC │ │ │
│ │ │ │ │ Gateway │ │ Peering │ │ │
│ │ └─────┘ └─────────┘ └──────────┘ │ │
│ │ Internet Outbound for Other VPC │ │
│ │ private subnet │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘

Component Table​

ComponentDescriptionMandatory
VPCIsolated virtual networkYes
SubnetSubnet in an AZYes (at least 1)
Route TableRouting rulesYes (auto-created)
Internet GatewayInternet accessNo (if private)
NAT GatewayInternet outbound for privateNo
Security GroupInstance-level firewallYes
NACLSubnet-level firewallYes (default)

Default VPC vs Custom VPC​

┌─────────────────────────────────────────────────────────────┐
│ DEFAULT VPC vs CUSTOM VPC │
├─────────────────────────────────────────────────────────────┤
│ │
│ DEFAULT VPC CUSTOM VPC │
│ ────────────── ──────────────── │
│ │
│ • Automatically created • You create it │
│ • 1 per region • As many as you want │
│ • CIDR: 172.31.0.0/16 • CIDR: you choose │
│ • Auto public subnets • You configure everything │
│ • IGW attached • You attach the IGW │
│ │
│ When to use: When to use: │
│ ✅ Quick tests ✅ Production │
│ ✅ Learning ✅ Enhanced security │
│ ❌ Production ✅ Multi-tier │
│ │
│ ⚠️ In production, ALWAYS use a custom VPC for better │
│ security control │
│ │
└─────────────────────────────────────────────────────────────┘

IP Address Range (CIDR)​

What is CIDR?​

┌─────────────────────────────────────────────────────────────┐
│ CIDR NOTATION │
├─────────────────────────────────────────────────────────────┤
│ │
│ CIDR = Classless Inter-Domain Routing │
│ │
│ Format: NETWORK_ADDRESS / PREFIX │
│ │
│ Example: 10.0.0.0/16 │
│ │ │ │
│ │ └── 16 fixed bits (network) │
│ │ 16 variable bits (hosts) │
│ │ │
│ └── Starting network address │
│ │
│ Calculating the number of addresses: │
│ Formula: 2^(32 - prefix) │
│ │
│ /16 = 2^(32-16) = 2^16 = 65,536 addresses │
│ /24 = 2^(32-24) = 2^8 = 256 addresses │
│ /28 = 2^(32-28) = 2^4 = 16 addresses │
│ │
└─────────────────────────────────────────────────────────────┘

Private Ranges (RFC 1918)​

┌─────────────────────────────────────────────────────────────┐
│ PRIVATE IP RANGES (RFC 1918) │
├─────────────────────────────────────────────────────────────┤
│ │
│ These ranges are NOT routed on the Internet │
│ → Use them for your VPCs │
│ │
│ CLASS A: 10.0.0.0/8 │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 10.0.0.0 → 10.255.255.255 │ │
│ │ 16,777,216 addresses │ │
│ │ Usage: Large enterprises │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ CLASS B: 172.16.0.0/12 │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 172.16.0.0 → 172.31.255.255 │ │
│ │ 1,048,576 addresses │ │
│ │ Usage: Medium enterprises │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ CLASS C: 192.168.0.0/16 │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ 192.168.0.0 → 192.168.255.255 │ │
│ │ 65,536 addresses │ │
│ │ Usage: Home networks, small businesses │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ RECOMMENDATION FOR AWS: │
│ Use 10.0.0.0/16 to start (65,536 addresses) │
│ │
└─────────────────────────────────────────────────────────────┘

AWS VPC Sizes​

CIDRAddressesRecommended Usage
/1665,536Standard VPC, recommended
/204,096Medium VPC
/24256Small VPC, test
/2816Minimum AWS
AWS Limits
  • Minimum CIDR: /28 (16 addresses)
  • Maximum CIDR: /16 (65,536 addresses)
  • A VPC can have multiple CIDRs (up to 5)

AWS Reserved Addresses​

┌─────────────────────────────────────────────────────────────┐
│ AWS RESERVED ADDRESSES PER SUBNET │
├─────────────────────────────────────────────────────────────┤
│ │
│ For each subnet, AWS reserves 5 addresses: │
│ │
│ Example: Subnet 10.0.1.0/24 (256 addresses) │
│ │
│ 10.0.1.0 → Network address │
│ 10.0.1.1 → Reserved by AWS (VPC router) │
│ 10.0.1.2 → Reserved by AWS (DNS) │
│ 10.0.1.3 → Reserved by AWS (future use) │
│ 10.0.1.255 → Broadcast (not supported but reserved) │
│ │
│ Usable addresses: 256 - 5 = 251 addresses │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Subnet /24: 251 usable addresses │ │
│ │ Subnet /25: 123 usable addresses │ │
│ │ Subnet /26: 59 usable addresses │ │
│ │ Subnet /27: 27 usable addresses │ │
│ │ Subnet /28: 11 usable addresses │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘

Typical VPC Architecture​

┌─────────────────────────────────────────────────────────────────────────┐
│ 3-TIER VPC ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ INTERNET │
│ │ │
│ ▼ │
│ ┌───────────────┐ │
│ │Internet Gateway│ │
│ └───────┬───────┘ │
│ │ │
│ ┌─────────────────────────────┼─────────────────────────────┐ │
│ │ VPC │(10.0.0.0/16) │ │
│ │ │ │ │
│ │ ┌─────────────────────────┴─────────────────────────┐ │ │
│ │ │ PUBLIC SUBNETS │ │ │
│ │ │ │ │ │
│ │ │ ┌─────────────────┐ ┌─────────────────┐ │ │ │
│ │ │ │ Public 1a │ │ Public 1b │ │ │ │
│ │ │ │ 10.0.1.0/24 │ │ 10.0.2.0/24 │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ │ [ALB/NAT] │ │ [ALB/NAT] │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ └────────┬────────┘ └────────┬────────┘ │ │ │
│ │ │ │ │ │ │ │
│ │ └───────────┼──────────────────────┼─────────────────┘ │ │
│ │ │ │ │ │
│ │ ┌───────────┼──────────────────────┼─────────────────┐ │ │
│ │ │ │ PRIVATE SUBNETS (App)│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ ┌────────▼────────┐ ┌────────▼────────┐ │ │ │
│ │ │ │ Private 1a │ │ Private 1b │ │ │ │
│ │ │ │ 10.0.11.0/24 │ │ 10.0.12.0/24 │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ │ [EC2 App] │ │ [EC2 App] │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ └────────┬────────┘ └────────┬────────┘ │ │ │
│ │ │ │ │ │ │ │
│ │ └───────────┼──────────────────────┼─────────────────┘ │ │
│ │ │ │ │ │
│ │ ┌───────────┼──────────────────────┼─────────────────┐ │ │
│ │ │ │ PRIVATE SUBNETS (DB) │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ ┌────────▼────────┐ ┌────────▼────────┐ │ │ │
│ │ │ │ Database 1a │ │ Database 1b │ │ │ │
│ │ │ │ 10.0.21.0/24 │ │ 10.0.22.0/24 │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ │ [RDS] │ │ [RDS Standby] │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ └─────────────────┘ └─────────────────┘ │ │ │
│ │ │ │ │ │
│ │ └────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘

Create a VPC​

Via Console​

1. VPC → Your VPCs → Create VPC
2. Name tag: my-vpc-prod
3. IPv4 CIDR block: 10.0.0.0/16
4. Tenancy: Default
5. Create VPC

Via AWS CLI​

# Create the VPC
aws ec2 create-vpc \
--cidr-block 10.0.0.0/16 \
--tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=my-vpc-prod}]'

# Enable DNS names (recommended)
aws ec2 modify-vpc-attribute \
--vpc-id vpc-xxx \
--enable-dns-hostnames '{"Value":true}'

Summary​

ConceptDescription
VPCIsolated virtual private network
CIDRNotation to define the IP range
SubnetSubdivision of the VPC in an AZ
/16Recommended size (65,536 IPs)
RFC 1918Private IP ranges to use
5 reserved IPsAWS reserves 5 IPs per subnet

Validation Quiz​

  1. What is a VPC?
  2. How many IP addresses in a /24?
  3. Why does AWS reserve 5 addresses per subnet?
  4. What IP range to use for a VPC?
  5. What is the difference between default and custom VPC?

Next section: Subnets and Routing