What Is a VPC? Cloud Networking for Beginners
Your web shop now has app servers, a database and storage. Before launch, a teammate asks which of these machines strangers on the internet can reach. Your network design decides. This lesson answers "what is a VPC?" and shows how subnets, gateways and firewalls steer traffic.
What is a VPC? Your own network in a region
A virtual private cloud (VPC) is a logically isolated private network that you create in one region. Logically isolated means your traffic shares the provider's cables and switches, but software keeps it apart from every other customer's network.
On AWS, a VPC spans all the availability zones of its region. Azure calls it a virtual network (VNet); on Google Cloud, a VPC network is global, with each subnet in one region.
Each server in a VPC gets a private IP address (an IP address, from lesson 3, is a computer's numeric address). Private addresses come from ranges that the public internet does not route.
You choose the VPC's range in CIDR notation (Classless Inter-Domain Routing): a starting address, a slash and a number. An IPv4 address has 32 bits, written as four numbers from 0 to 255; the number after the slash says how many bits, from the left, are fixed.
In 10.0.0.0/16, the first 16 bits (10.0) are fixed and 16 are free: 65,536 addresses, from 10.0.0.0 to 10.0.255.255. A bigger number means a smaller range: 10.0.1.0/24 holds 256.
The private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Avoid ranges used by networks you may connect later, such as your office's: overlapping networks are hard to join.
Subnets: public and private slices
A subnet is a slice of the VPC's range, such as 10.0.1.0/24. On AWS, each subnet lives in one availability zone, so surviving a zone failure takes subnets in at least two. Azure subnets, by contrast, span all the zones of their region.
AWS allows subnets from /16 down to /28 (16 addresses) and reserves the first four and the last address of each, so a /24 leaves 251 for your servers.
A subnet is public because of its route, not a setting. A public subnet can send traffic to an internet gateway, so a server there with a public IP address, one reachable from the internet, can talk both ways. A private subnet has no such route, so the internet cannot reach its servers.
In the diagram, notice that private subnets get out only through a NAT gateway, one way.
Gateways and route tables: where traffic goes
A route table is a list of routes that decides where traffic leaving a subnet goes next. Each route has a destination range and a target, where matching traffic is sent. Every subnet uses one route table, and several subnets can share one.
If several routes match, AWS picks the most specific: the one covering the fewest addresses. 0.0.0.0/0 matches every IPv4 address, so it catches the rest. AWS also adds a local route for the VPC's own range, keeping traffic between your subnets inside.
The two kinds of subnet differ in one route:
| Destination | Public subnet's target | Private subnet's target |
|---|---|---|
10.0.0.0/16 | local | local |
0.0.0.0/0 | Internet gateway | NAT gateway in the same zone |
An internet gateway connects a VPC to the internet, and AWS runs it for you. A server using it needs a public IPv4 address, which AWS maps to its private one by network address translation (NAT), rewriting addresses on traffic as it passes. The server itself sees only its private address.
A NAT gateway does this in one direction only. Private servers can start connections out, say to download updates, and get the replies, but nothing on the internet can start a connection in. The default, zonal kind sits in a public subnet with a fixed public address, called an Elastic IP.
With one NAT gateway per zone, as in the diagram, losing a zone does not cut off the other; AWS also offers a regional mode spanning zones. NAT gateways are billed by the hour and per gigabyte, a classic surprise in Cloud Cost Basics.
Firewalls: security groups and network ACLs
A firewall is a set of rules that allows or blocks traffic, often by port, the number that picks which program on a server gets it, such as 443 for HTTPS. A VPC has two kinds, and they differ in memory.
A security group is attached to an instance: strictly, to its network interface, its virtual network card. Its rules can only allow; anything else is blocked. A new group allows no inbound and all outbound traffic. A rule's source can be an address range or another security group.
Security groups are stateful: they track each connection, so the reply to any allowed request gets through, whatever the rules for the reply's direction say.
A network ACL (access control list) is attached to a subnet and checks every packet, a small chunk of network data, crossing its edge. Every subnet has one; the default allows everything. Its numbered rules can allow or deny, checked from the lowest number up; the first match decides.
Network ACLs are stateless: they remember nothing, so replies need rules of their own. A reply returns to a temporary high-numbered port, so an ACL allowing only port 443 inbound breaks your server's own downloads.
When a server cannot reach the internet, work through the flowchart; its order is a troubleshooting habit, not the packet's path. Notice that one No anywhere blocks it.
A typical layout: three tiers across two zones
Most web apps use the first diagram's layout in three tiers, layers with one job each. The load balancer sits in the public subnets; on AWS, an Application Load Balancer needs subnets in at least two zones. App servers and the database sit in private subnets.
The security groups form a chain. The load balancer's allows port 443 from anywhere; the app servers' allows their port only from the load balancer's group; the database's allows its port, such as 5432 for PostgreSQL, only from the app servers' group.
Follow one request; notice that only the load balancer needs a public address.
Check yourself
A server in a private subnet cannot download updates, though its security group allows all outbound traffic. What do you check first, and why?
The subnet's route table: without a 0.0.0.0/0 route to a NAT gateway, the traffic has nowhere to go, whatever the firewalls allow.
A network ACL allows outbound HTTPS, yet downloads fail, while a security group with the same single rule works. Why?
The ACL is stateless, so replies returning to the server's temporary port need an inbound rule of their own; the stateful security group lets them in automatically.
A teammate wants to move the app servers into a public subnet so they can fetch updates. What would that cost you?
With public IPs, only their security group would stand between them and the internet; a NAT gateway already brings updates while no one can connect in.