Course contentsShow
← Security
Lesson 1829 of 3,05237. Cloud Security - Network ArchitectureFree lesson

Public vs Private Subnets

Distinguishing public subnets with internet access from private subnets and their security implications.

Public vs Private Subnets

What you'll learn: How to distinguish public and private subnets in cloud networks and understand their critical security implications.

The Core Distinction

In cloud VPCs, subnets come in two fundamental flavors: public and private. The difference isn't just a label—it's about internet connectivity and exposure.

A public subnet has a route to an Internet Gateway (IGW), allowing resources within it to send and receive traffic directly from the internet. Think of it as having a front door that opens onto a public street—anyone can potentially knock.

A private subnet has no direct internet route. Resources here cannot be reached from the internet by default, and cannot initiate direct outbound connections either. It's like a room with no exterior doors—visitors must enter through controlled pathways only.

Security Implications

Public subnets should host only resources that must face the internet:

  • Load balancers
  • Bastion hosts (jump boxes)
  • NAT gateways
  • Public-facing web servers

The security risk: every resource here is potentially reachable from the internet, making them prime attack targets.

Private subnets should contain sensitive workloads:

  • Application servers
  • Databases
  • Internal microservices
  • Backend processing systems

The security advantage: attackers cannot directly access these resources, reducing your attack surface dramatically.

The Pattern

A common secure architecture places load balancers in public subnets that forward traffic to application servers in private subnets. Private resources can still access the internet for updates via a NAT Gateway (which lives in a public subnet), but inbound connections are blocked.

Key Takeaway: Public subnets expose resources to the internet and should only host edge infrastructure, while private subnets isolate sensitive workloads behind network boundaries—making subnet classification your first line of architectural defense in cloud security.