Course contentsShow
← Cloud and Infrastructure
Lesson 176 of 2,9894. Cloud Networking BasicsFree lesson

Public vs Private Subnets

Learn the differences between public and private subnets and their typical use cases.

Public vs Private Subnets

What you'll learn: You'll understand the key differences between public and private subnets and when to use each in your cloud architecture.

The Core Distinction

Within your Virtual Network, not all subnets are created equal. A public subnet is one whose resources can directly communicate with the internet, while a private subnet houses resources that should remain isolated from direct internet access.

The difference isn't just conceptual—it's enforced through routing. A public subnet has a route table that directs internet-bound traffic (0.0.0.0/0) to an internet gateway, giving instances inside it public IP addresses and internet access. A private subnet lacks this direct route to an internet gateway.

Real-World Analogy

Think of a hotel: the lobby (public subnet) faces the street with direct access for guests to come and go. The back offices and storage rooms (private subnets) have no street-facing doors—they're accessible only from inside the building.

Typical Use Cases

Public Subnets:

  • Web servers that users access directly
  • Load balancers accepting incoming traffic
  • Bastion hosts (jump boxes) for administrative access

Private Subnets:

  • Application servers processing business logic
  • Databases storing sensitive data
  • Internal microservices
  • Background processing workers

Private resources can still access the internet outbound (for updates, API calls) through a NAT Gateway placed in a public subnet—but inbound connections from the internet cannot reach them directly.

Key Takeaway: Public subnets expose resources to the internet via direct routing, while private subnets provide an isolated layer of defense where sensitive components run protected from direct internet access.