AWS VPC Explained: Subnets, Routes, Internet Gateway and NAT Gateway
A practical introduction to AWS VPC networking and how subnets, route tables, Internet Gateway, and NAT Gateway work together.
AWS VPC Explained: Subnets, Routes, Internet Gateway and NAT Gateway
When learning AWS infrastructure, networking is one of the areas that requires a strong understanding of how different components work together.
AWS Virtual Private Cloud (VPC) provides the networking foundation for many AWS workloads. Instead of looking at each networking component separately, I wanted to understand how VPCs, subnets, route tables, Internet Gateways, and NAT Gateways work together.
What is an AWS VPC?
An Amazon VPC is a logically isolated virtual network that can be used to run AWS resources.
When creating a VPC, we define important networking components such as:
- IPv4 CIDR block
- Subnets
- Route tables
- Internet Gateway
- NAT Gateway
- Security Groups
- Network ACLs
The VPC provides the network boundary, while these components control how resources communicate.
Understanding Subnets
A subnet is a range of IP addresses within a VPC.
Subnets are generally associated with an Availability Zone.
For example, an architecture could have:
VPC
→ Public Subnet
→ Private Subnet
A common design is to place internet-facing resources in public subnets while keeping internal application or database resources in private subnets.
What Makes a Subnet Public?
One important lesson I learned is that a subnet is not simply public because we call it a "public subnet."
Its routing configuration matters.
A subnet is considered public when its associated route table contains a route that provides a path to an Internet Gateway.
For example:
0.0.0.0/0 → Internet Gateway
This allows resources with appropriate networking configuration to communicate with the internet.
Route Tables
Route tables determine where network traffic is directed.
A route can contain:
- Destination
- Target
For example:
Destination: 0.0.0.0/0
Target: Internet Gateway
This means traffic destined for addresses outside the VPC can be routed toward the Internet Gateway.
Understanding route tables helped me realize that networking problems are often caused not by the resource itself, but by how traffic is being routed.
Internet Gateway
An Internet Gateway provides a path between a VPC and the internet.
For an internet-facing workload, the general flow can look like:
Internet → Internet Gateway → Public Subnet → Resource
However, simply attaching an Internet Gateway to a VPC does not automatically make every resource publicly accessible.
Other factors such as:
- Route tables
- Public IP addresses
- Security Groups
- Network ACLs
also affect connectivity.
NAT Gateway
Private resources may still need outbound internet access.
For example, a private application server may need to download operating system updates or access an external API.
A common architecture is:
Private Subnet → NAT Gateway → Internet Gateway → Internet
The NAT Gateway is placed in a public subnet.
Private subnet resources can use the NAT Gateway for outbound connectivity without requiring a public IP address on those resources.
Public vs Private Subnet
A simple architecture can look like this:
Internet
↓
Internet Gateway
↓
Public Subnet
↓
NAT Gateway / Load Balancer
↓
Private Subnet
↓
Application / Database
This separation can improve security and provides a better foundation for designing multi-tier applications.
Security Groups and Network ACLs
Routing determines where traffic can go, but network security controls determine whether traffic should be allowed.
Security Groups
Security Groups act as virtual firewalls associated with resources such as EC2 instances.
They control inbound and outbound traffic using rules.
Network ACLs
Network ACLs operate at the subnet level.
They provide another layer of network traffic control.
Understanding the difference between Security Groups and Network ACLs is important when troubleshooting connectivity.
A Simple Three-Tier Architecture
A common cloud architecture can separate workloads into different layers:
Public Layer
Load Balancer
↓
Application Layer
Application Servers
↓
Data Layer
Database
The application and database layers can remain in private subnets while only the required public-facing components are exposed to the internet.
What I Learned
The biggest lesson for me is that AWS networking is about understanding relationships.
A VPC by itself does not explain connectivity.
I need to understand:
VPC → Subnet → Route Table → Gateway → Security Controls → Resource
When troubleshooting connectivity, looking at these components together makes it much easier to identify where the problem exists.
My Next Step
I want to continue practicing AWS networking through hands-on scenarios involving:
- VPC creation
- Public and private subnets
- Route tables
- Internet Gateway
- NAT Gateway
- Security Groups
- Network ACLs
- Load Balancers
- Multi-tier architectures
My goal is to move from simply understanding networking concepts to confidently designing and troubleshooting AWS network architectures.
Final Thoughts
AWS networking provides the foundation for secure and reliable cloud infrastructure.
The most useful lesson for me has been to stop thinking about networking components individually and instead understand how traffic flows through the architecture.
Once that traffic flow becomes clear, concepts such as public and private subnets, routing, and gateways become much easier to understand.
Understand the traffic flow. Design the network. Secure the workload.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article