What is a Subnet in AWS? Public vs Private Subnets Explained (2026)

Learn what a subnet in AWS is and how public and private subnets work. Complete beginner-friendly guide with architecture, routing, and real-world examples.

Introduction

A subnet in AWS is a smaller network inside a Virtual Private Cloud (VPC) that helps you organize and secure your cloud resources.

If you don’t understand subnets, you don’t understand AWS networking.

In this guide, you’ll learn:

  • What a subnet is
  • Types of subnets
  • How routing works
  • Real-world architecture
  • Common mistakes beginners make

What is a Subnet in AWS?

A subnet (short for subnetwork) is a division of a VPC’s IP address range into smaller segments.

In Amazon Web Services, subnets allow you to:

  • Organize resources
  • Control network traffic
  • Apply security boundaries

TL/DR

A subnet is a logical partition of a VPC where you place your AWS resources like EC2 instances.


Why Subnets Are Important

Without subnets:

  • All resources are in one flat network
  • No proper isolation
  • Security risks increase

With subnets:

  • You separate public and private resources
  • Control access using routing
  • Build secure architectures

Types of Subnets in AWS

There are two main types of subnets:

1. Public Subnet

A public subnet is a subnet that has access to the internet.

Key Features:

  • Connected to Internet Gateway
  • Can have public IP addresses
  • Accessible from outside

Used For:

  • Web servers
  • Load balancers
  • Bastion hosts

2. Private Subnet

A private subnet does NOT have direct internet access.

Key Features:

  • No route to Internet Gateway
  • No public IP
  • More secure

Used For:

  • Databases
  • Backend servers
  • Internal services

How Public and Private Subnets Work

The difference between public and private subnets is not the subnet itself—it’s the route table configuration.

Public Subnet Routing:

0.0.0.0/0 → Internet Gateway

This means:

  • Traffic can go to the internet

Private Subnet Routing:

0.0.0.0/0 → NAT Gateway (optional)

This means:

  • Outbound internet allowed
  • No inbound access

Real-World Architecture Example

In a production setup:

Public Subnet:

  • Load Balancer
  • Bastion Host

Private Subnet:

  • Application Servers
  • Database

Why?

  • Public layer handles incoming traffic
  • Private layer protects sensitive data

This is a standard architecture used in most cloud systems.


Subnet CIDR Block Explained

Each subnet gets a portion of the VPC’s IP range.

Example:

VPC:

10.0.0.0/16

Subnets:

10.0.1.0/24 (Public)
10.0.2.0/24 (Private)

This helps:

  • Organize IP allocation
  • Avoid conflicts
  • Scale efficiently

Best Practices for Subnets

  • Use at least 2 subnets across different Availability Zones
  • Keep databases in private subnets
  • Do not assign public IP unnecessarily
  • Use NAT Gateway for outbound access
  • Design CIDR blocks carefully

Common Mistakes Beginners Make 

  • Thinking subnet type is automatic
  • Not configuring route tables
  • Putting databases in public subnet 
  • Using default VPC without planning

How Subnets Relate to Other AWS Components

Subnets work together with:

  • VPC → main network
  • Route Tables → control traffic
  • Internet Gateway → public access
  • NAT Gateway → private outbound access
  • Security Groups → instance-level security

Understanding this relationship is key to mastering AWS networking.


Conclusion

Subnets are the building blocks of AWS networking in Amazon Web Services.

If you understand:

  • Public vs Private subnets
  • Routing logic
  • Real-world architecture

You are already ahead of most beginners in cloud computing.

Anup Das
As, India

Comments

Popular posts from this blog

Secure AWS VPC Setup with Bastion Host (Step-by-Step Guide for Beginners) | 2026

How AWS VPC Works: A Deep-Dive Guide to Virtual Private Cloud (Architecture, Security & Best Practices)

Advantages of Cloud Computing: Why Businesses Are Moving to the Cloud in 2026