Networking Tutorial · Cloud Networking · Lesson 22 of 28

Virtual Private Clouds (VPC)

What a VPC is, how to choose its address range, and how AWS VPCs compare with Azure VNets and Google Cloud VPCs.

Create a free account to save this page, take notes and track your progress. Sign in

What is a VPC?

A virtual private cloud is your own isolated network inside a cloud provider. You choose its private address range, divide it into subnets, and control routing and firewalls. Servers, containers, databases and load balancers get addresses from it.

AWS Azure Google Cloud
Network VPC Virtual network (VNet) VPC network
Scope One region One region Global
Subnet scope One availability zone Whole region (zone-spanning) One region
Address range Set on the VPC (/16 to /28), extra ranges can be added Set on the VNet Set per subnet
Reserved per subnet 5 5 4

Choosing the range

  • Use private space, normally inside 10.0.0.0/8.
  • Make it big enough to grow: a /16 per environment and region is common. Kubernetes and serverless functions can use many addresses.
  • Never overlap with networks you may connect later: other VPCs, offices, partners, the VPN range. Overlapping networks can't be peered or routed to each other. Plan ranges centrally (AWS VPC IP Address Manager, Azure IPAM, or a simple shared spreadsheet).
Check an address plan for overlapsTry it yourself
import ipaddress

plan = {
    "office":        "10.0.0.0/16",
    "prod-eu":       "10.20.0.0/16",
    "staging-eu":    "10.21.0.0/16",
    "partner-vpn":   "10.20.128.0/20",
}
nets = {name: ipaddress.ip_network(cidr) for name, cidr in plan.items()}
names = list(nets)
for i, a in enumerate(names):
    for b in names[i + 1:]:
        if nets[a].overlaps(nets[b]):
            print(f"OVERLAP: {a} {nets[a]} and {b} {nets[b]}")
print("checked", len(names), "ranges")

Output

OVERLAP: prod-eu 10.20.0.0/16 and partner-vpn 10.20.128.0/20
checked 4 ranges

Defining a VPC as code

resource "aws_vpc" "main" {
  cidr_block           = "10.20.0.0/16"
  enable_dns_hostnames = true
  tags = { Name = "prod-eu-west-1" }
}

See the Terraform tutorial to create networks like this as code.

Test yourself

Why must VPC address ranges not overlap?

  1. Overlapping networks can't be peered or routed to each other
  2. Overlaps make DNS slower
  3. Cloud providers charge extra for overlaps
  4. Overlaps disable security groups
Show answer

Answer: Overlapping networks can't be peered or routed to each other

A router can't tell which network an overlapping address belongs to, so peering and VPN routes between them are rejected or ambiguous.

Was this page helpful?