AWS Builder Center
AWS Networking:Amazon VPC, Subnets, Routing & Security

AWS Networking:Amazon VPC, Subnets, Routing & Security

Learn AWS networking with real examples. Understand Amazon VPC, public and private subnets, route tables, internet gateways, security groups, NACLs, and EC2.

Series: Skill Builder Digital Classroom - AWS Cloud Technical Essentials (11 articles)

  1. …
  2. 4
    AWS Networking:Amazon VPC, Subnets, Routing & Security This article

AWS Networking Explained: The Complete Amazon VPC, Subnets, Routing & Security Guide (2026)

Your AWS Application Is Only as Secure as the Network Around It

You can launch an EC2 instance in minutes.
You can deploy a web application with a few clicks.
You can even build an entire cloud infrastructure without owning a single physical server.
But here's the question many beginners forget to ask:
Who can actually reach your application?
Imagine building an Employee Directory application for a company. Employees need to access its website. Its database needs to stay protected. The application needs reliable connectivity, and the infrastructure should survive the failure of a single Availability Zone.
Launching an EC2 instance won't solve all those problems.
The real decisions happen in the network.
That's where AWS networking and Amazon Virtual Private Cloud (Amazon VPC) come in.
AWS networking isn't just about connecting resources. It's about deciding which connections should exist and which should never happen.
In this guide, you'll learn the core concepts of AWS networking, understand how traffic moves through a VPC, configure public and private subnets, compare security groups with network ACLs, and follow a practical Employee Directory application deployment.
You'll also learn how these foundational concepts fit into modern AWS architecture.

AWS networking diagram showing how internet traffic reaches an Employee Directory application hosted


1. Introduction to AWS Networking: Understand the Basics Before Building

Before configuring an Amazon VPC, you need to understand three ideas: IP addresses, CIDR notation, and network communication.

What is networking?

Networking is the process of connecting computers, servers, and other devices so they can exchange information.
Think about sending a package.
You need the sender's address, the recipient's address, and a delivery system that knows which direction to send it.
Computer networks operate on a similar principle.
When someone visits your website, their device sends a request. That request contains addressing information that allows networking equipment to move it toward your application. The application then sends a response.
In AWS, services such as VPC, route tables, and internet gateways help establish the paths used for that communication.

What is an IP address?

An Internet Protocol (IP) address identifies a network interface and helps network traffic reach its destination.
For example:
 192.168.1.30 
This is an IPv4 address.
IPv4 addresses contain 32 bits, represented in four groups called octets. Each octet ranges from 0 to 255.
AWS supports both IPv4 and IPv6 addressing in VPCs. IPv6 uses 128-bit addresses, providing a much larger address space.


What is CIDR notation in AWS?

Classless Inter-Domain Routing (CIDR) notation defines a range of IP addresses.
Consider:
 10.1.0.0/16 
The  /16  means the first 16 bits identify the network portion. The remaining 16 bits provide address combinations within that range.
Here is a practical comparison:
CIDR block
Total IPv4 addresses
Typical use
 10.1.0.0/16 
65,536
Large VPC range
 10.1.1.0/24 
256
Application subnet
 10.1.1.0/28 
16
Small subnet
A larger prefix number means a smaller IPv4 address block.
AWS supports IPv4 VPC CIDR blocks ranging from  /16  to  /28 . A VPC can have five IPv4 CIDR blocks by default, with an adjustable quota.

Important: The total number of addresses is not the same as the number available for EC2 instances. AWS reserves five IPv4 addresses in each subnet. For example, a  /24  subnet provides 251 usable IPv4 addresses.


Diagram comparing AWS CIDR block sizes with three progressively smaller network ranges: /16 showing


2. Amazon VPC Explained: Your Private Network Inside AWS

An Amazon VPC is a logically isolated virtual network where you define networking configurations for AWS resources.
It allows you to control IP addressing, subnets, routing, connectivity, and network security.
Think of a VPC as the boundaries of your company's digital property.
Inside those boundaries, you decide where servers are placed, how they communicate, and which resources need access to external networks.
Unlike a physical office network, you don't need to purchase routers, cables, or networking equipment to create the basic infrastructure.
AWS provides the underlying infrastructure. You define the configuration.

How does an Amazon VPC work?

When creating a VPC, the essential choices include:
  1. AWS Region: The geographic Region where the network exists.
  1. IPv4 CIDR block: The address range available to the VPC.
  1. VPC name: A descriptive Name tag for identification.
For our Employee Directory application, we'll use:
Setting
Configuration
AWS Region
US West (Oregon),  us-west-2 
VPC name
 app-vpc 
IPv4 CIDR
 10.1.0.0/16 
Availability Zones
Two
Subnets
Four
An Amazon VPC spans Availability Zones within a selected Region. Individual subnets, however, are created within a particular Availability Zone.

Public subnet vs private subnet: What's the difference?

This is one of the most important concepts in AWS networking.
A public subnet has a route to an internet gateway. It's commonly used for internet-facing components such as public load balancers.
A private subnet does not have a direct route to an internet gateway. It's commonly used for internal applications, databases, and private backend workloads.
But here's something beginners often miss:
A subnet doesn't become public because you name it "Public." It becomes public because of its routing configuration.
And even in a public subnet, an EC2 instance generally needs a public IP address and appropriate firewall rules to communicate directly with the internet over IPv4.

Why use multiple Availability Zones?

Imagine hosting your Employee Directory on a single EC2 instance inside one Availability Zone.
If that instance or Availability Zone becomes unavailable, employees may lose access.
Now imagine deploying application instances across two Availability Zones, with a load balancer distributing requests between them.
The architecture is more resilient to an individual Availability Zone failure.
For our example, we'll create four subnets:
Subnet
Availability Zone
CIDR
Public Subnet 1
 us-west-2a 
 10.1.1.0/24 
Private Subnet 1
 us-west-2a 
 10.1.2.0/24 
Public Subnet 2
 us-west-2b 
 10.1.3.0/24 
Private Subnet 2
 us-west-2b 
 10.1.4.0/24 
All four address ranges fit within  10.1.0.0/16 , and none overlap.
Creating subnets across two Availability Zones provides the foundation for high availability. But high availability also requires appropriately replicated workloads and traffic distribution. Merely creating a second subnet does not make a single EC2 instance highly available.


Amazon VPC architecture with four public and private subnets across two AWS Availability Zones.


What are internet gateways, virtual private gateways, and AWS Direct Connect?

Amazon VPC supports different connectivity options for different business needs.
Internet Gateway (IGW): Connects your VPC to the internet when used with appropriate routes, addresses, and security rules.
Virtual Private Gateway (VGW): Can provide the AWS-side endpoint for a Site-to-Site VPN connection between your VPC and another private network.
AWS Direct Connect: Provides dedicated network connectivity between your environment and AWS through a Direct Connect location. Encryption requirements should be considered separately from the physical connection.
The decision is simple: choose the connectivity method that matches where your users and systems live.
A public website, an internal company application, and a private data center connection do not necessarily need the same network architecture.

3. Amazon VPC Routing: How AWS Decides Where Traffic Goes

An internet gateway gives your VPC a connection to the internet.
But a connection is not enough.
Imagine a delivery truck reaching the gate of a large business campus. The gate lets it enter, but the driver still needs directions to the correct building.
In AWS, route tables provide those directions.

What is an AWS route table?

A route table contains rules that determine where network traffic should be directed.
Each route generally contains a destination address range and a target.
For example:
Destination
Target
Purpose
 10.1.0.0/16 
 local 
VPC-local traffic
 0.0.0.0/0 
Internet Gateway
Default IPv4 internet route
When you create a VPC, AWS provides a main route table.
Its initial local route allows destinations inside the VPC address range to be routed internally. Security groups and network ACLs can still prevent communication.
Subnets without an explicit custom route-table association use the VPC's main route table.

How do you make an AWS subnet public?

For our Employee Directory example:
  1. Create an internet gateway named  app-igw .
  1. Attach it to  app-vpc .
  1. Create a route table named  public-route-table .
  1. Add a default IPv4 route:  0.0.0.0/0  →  app-igw .
  1. Associate the route table with Public Subnet 1 and Public Subnet 2.
That's the route-table configuration needed to make those subnets public.
For our private subnets, we'll retain the local route without a direct internet gateway route.
Route tables determine the network path; they are not firewalls and do not override security rules.


AWS route table example comparing public and private subnet routing.


How can private subnets access the internet?

A private subnet may still need outbound internet connectivity.
For example, a backend EC2 instance might need to download software updates or communicate with an external API.
One common solution is a NAT gateway.
A NAT gateway can allow private resources to initiate outbound connections without allowing unsolicited inbound internet connections to those resources.

AWS also documents Regional NAT Gateways, which can automatically expand across Availability Zones based on workload presence, in addition to traditional zonal NAT gateways. This is a useful modernization beyond the original course's basic VPC routing example.

For workloads accessing supported AWS services, VPC endpoints may provide private connectivity without needing internet gateway or NAT routing.
The goal isn't to give every server internet access. It's to provide only the connectivity each workload requires.

4. Amazon VPC Security: Security Groups vs Network ACLs

Now your application has a network.
Your subnets have routes.
Your internet gateway is connected.
But there's another question:
Just because traffic can find your server, should that traffic be allowed inside?
This is where security becomes critical.
AWS provides two foundational networking controls: security groups and network access control lists (NACLs).
They protect different layers of your architecture.

What is an AWS security group?

A security group is a virtual firewall for associated AWS resources, including EC2 instances through their network interfaces.
It controls allowed inbound and outbound traffic.
When you create a new custom security group, it starts with:
  • No inbound rules, so inbound traffic is blocked.
  • An outbound rule that allows all outbound traffic.
Security groups are stateful, meaning permitted connection traffic can receive a response without requiring a matching reverse-direction rule.

For a web server, example inbound rules might look like this:
Type
Protocol
Port
Source
HTTP
TCP
80
 0.0.0.0/0 
HTTPS
TCP
443
 0.0.0.0/0 
Those example rules permit HTTP and HTTPS requests from any IPv4 address.
For production, prioritize HTTPS, use TLS appropriately, and restrict access to only what the application requires.
One distinction matters: the VPC's default security group is not identical to a newly created custom security group. The default security group includes an inbound rule allowing traffic from other resources associated with that same security group. It does not allow unrestricted inbound internet traffic.

What is a network ACL in AWS?

A network access control list is a subnet-level traffic filter.
It evaluates rules for traffic entering and leaving a subnet.
Unlike security groups, network ACLs are stateless.
That means return traffic must be explicitly permitted by the appropriate inbound or outbound rules.
For example, allowing an HTTPS request to enter on TCP port 443 is not enough by itself. A restrictive NACL must also allow the server's response to leave using the destination's ephemeral port.
AWS's default network ACL permits inbound and outbound traffic. However, a newly created custom network ACL starts with rules that deny all inbound and outbound traffic until you add allow rules.

Security group vs NACL: Key differences

Feature
Security Group
Network ACL
Protection level
Resource / network interface
Subnet
Stateful?
Yes
No
Allow rules
Yes
Yes
Deny rules
No
Yes
Rule evaluation
Combined allow rules
Numbered rules in order
Response traffic
Automatically permitted for tracked connections
Must be explicitly allowed
Primary purpose
Workload access control
Additional subnet traffic filtering
AWS recommends security groups as a primary resource-level security control, with network ACLs providing an additional layer when needed.

Amazon Virtual Private Cloud


Comparison diagram showing how AWS network ACLs filter subnet traffic and security groups filter EC2


The three-tier security pattern

Consider a typical web application with three layers:
Web tier: Receives HTTPS traffic from an approved external entry point.
Application tier: Accepts requests only from the web tier over the required application port.
Database tier: Accepts database connections only from the application tier.
The important design principle is that the database should not accept direct connections from arbitrary internet clients.
Where appropriate, use security-group references rather than broad IP ranges to permit communication between the tiers.
This creates a controlled communication chain rather than an unrestricted network.


Secure three-tier AWS architecture using security groups to restrict traffic between web, applicatio


5. Hands-On AWS VPC Tutorial: Deploy the Employee Directory Application

Theory becomes useful when you can apply it.
Let's build the network described in Module 3 and use it to host the Employee Directory application on Amazon EC2.
The following exercise follows the course's final four-subnet demonstration, with updated recommendations for 2026.

Step 1: Create a custom VPC

Sign in to the AWS Management Console.
Open VPC → Your VPCs → Create VPC.
Choose the VPC-only creation option and configure:
Setting
Value
Name
 app-vpc 
IPv4 CIDR
 10.1.0.0/16 
Region
US West (Oregon)
Tenancy
Default
Select Create VPC.
You now have an isolated virtual network ready for additional networking resources.

Step 2: Create four subnets

Navigate to VPC → Subnets → Create subnet.
Select  app-vpc .
Create the following subnets:
Name
Availability Zone
IPv4 CIDR
Public Subnet 1
us-west-2a
 10.1.1.0/24 
Private Subnet 1
us-west-2a
 10.1.2.0/24 
Public Subnet 2
us-west-2b
 10.1.3.0/24 
Private Subnet 2
us-west-2b
 10.1.4.0/24 
Confirm that none of the address ranges overlap.
At this stage, the names don't determine internet accessibility. Routing will do that.

Step 3: Create and attach an internet gateway

Navigate to VPC → Internet Gateways → Create internet gateway.
Name it  app-igw , create it, and attach it to  app-vpc .
Remember: An internet gateway attached to a VPC doesn't automatically make every EC2 instance internet-accessible.
You still need routes, appropriate IP addressing, and security permissions.

Step 4: Configure the public route table

Open VPC → Route Tables → Create route table.
Name it  public-route-table  and select  app-vpc .
Then add the route:
Destination: 0.0.0.0/0
Target: app-igw
Associate this route table with Public Subnet 1 and Public Subnet 2.
Leave the two private subnets using the main route table's local-only routing for this exercise.

Step 5: Create a security group

Navigate to EC2 → Security Groups → Create security group.
Configure the following:
Setting
Value
Name
 employee-directory-sg 
VPC
 app-vpc 
Inbound HTTP
TCP 80
Inbound HTTPS
TCP 443
Outbound
Default allow-all for this lab
For this basic public web demo, the inbound source can be  0.0.0.0/0 , but expose only ports your application actually serves. An HTTPS rule alone doesn't configure TLS on the web server; you'll need an appropriate certificate and HTTPS listener.
Avoid opening SSH port 22 to the entire internet. For administrative access, consider AWS Systems Manager Session Manager and a suitable IAM role.

Step 6: Launch your EC2 instance

Navigate to EC2 → Instances → Launch instance.
Configure the instance using these example settings:
Setting
Value
Instance name
Employee Directory App
AMI
Amazon Linux 2023
Instance type
A compatible, appropriately sized EC2 type
VPC
 app-vpc 
Subnet
Public Subnet 1
Auto-assign public IP
Enabled
Security group
 employee-directory-sg 
2026 update: The original training demonstration uses Amazon Linux 2. AWS states that Amazon Linux 2 reached end of support on June 30, 2026, and recommends migrating to Amazon Linux 2023. For latest deployment, select a supported operating system and ensure your application's installation scripts are compatible.

Deploy your Employee Directory application using a compatible installation method, configure the web server, and verify that its service is running before testing internet access.

Step 7: Test the application

After the EC2 instance enters the Running state, check its networking details.
Confirm:
  • The instance has a public IPv4 address.
  • It is in Public Subnet 1.
  • The subnet has a default route to  app-igw .
  • The security group allows the required inbound web traffic.
  • The web server is running and listening on the expected port.
For a basic HTTP lab, visit:
 http://YOUR-PUBLIC-IP 
If the application responds, the network path is functioning for that request.
If it doesn't, troubleshoot the application, instance configuration, routes, IP addresses, and security rules rather than assuming the VPC itself is broken.


AWS Employee Directory EC2 deployment in a custom VPC with two public subnets, two private subnets,


Common AWS networking problems and how to fix them

Problem
Likely cause
What to check
EC2 website won't load
Incorrect security or route configuration
Public IP, security group, route table
EC2 cannot reach the internet
Missing internet route or address
IGW, route target, public IP or NAT
Private EC2 cannot download updates
No outbound path
NAT gateway or VPC endpoints
Database connection fails
Missing allowed traffic
Database security group and listener
Custom NACL blocks responses
Missing return-traffic rule
Ephemeral ports and NACL rules
Application works in one AZ only
Single deployed workload
Replication and load balancing
A useful troubleshooting habit is to follow the packet's journey.
Don't change five settings at once. Identify the first point where the expected connection stops working.

6. AWS Networking Best Practices for 2026

The course provides a strong foundation. Production environments usually need additional layers.
Here are five improvements worth prioritizing.

1. Keep application servers private when possible

Instead of exposing every EC2 instance directly to the internet, place an internet-facing Application Load Balancer in public subnets and application instances in private subnets.
This reduces direct public exposure while allowing customers to reach the application.

2. Design for failure, not just successful deployment

Use more than one Availability Zone for workloads that require high availability.
For supported architectures, pair multiple application instances with load balancing, health checks, and appropriate database recovery or replication mechanisms.

3. Apply least-privilege network rules

Every inbound rule should have a purpose.
Allow only the ports, protocols, and sources required by the application.
Review unrestricted inbound rules regularly, especially for administrative services.

4. Monitor the network

Use VPC Flow Logs to capture network traffic metadata for troubleshooting and analysis.
Consider AWS security monitoring capabilities where appropriate.
Flow Logs can help you investigate traffic patterns, but they are not a full substitute for application logs or packet-level inspection.

5. Understand what AWS networking costs

Creating a basic VPC does not mean every related resource is free.
NAT gateways incur hourly and data-processing charges. Public IPv4 addresses are billable, and EC2, load balancers, and data transfer can introduce additional costs. Check current Regional pricing before deploying a lab.

Delete temporary workloads and billable network resources when your practice environment is no longer needed.

Comparison of a beginner AWS VPC deployment and a more resilient production AWS network architecture


7. AWS Networking Knowledge Check: Test Your Understanding

Before moving to advanced AWS services, confirm that you understand the fundamentals.
5-question AWS networking quiz

1. What is the main purpose of an Amazon VPC?

Store files


Create an isolated virtual network


Manage IAM users


Run SQL queries

2. What makes a subnet public?

Its name


A security group


A direct route to an internet gateway


An EC2 instance

3. What is the default behavior of a newly created custom security group?

Allow all inbound traffic


Block inbound and allow outbound traffic


Allow all traffic


Block all inbound and outbound traffic

4. Which AWS networking control is stateless?

Security group


Network ACL


Amazon VPC


Internet gateway

5. How many IPv4 addresses can AWS assign to resources in a /24 subnet?

256


250


251


255

An AWS  /24  subnet contains 256 total IPv4 addresses.
AWS reserves 5 IP addresses in each subnet for networking purposes.
Calculation:
256 − 5 = 251 usable IPv4 addresses

8. AWS Networking FAQs

What is AWS networking in simple terms?

AWS networking is the collection of services and configurations that enable cloud resources to communicate securely with one another, with external networks, and with users. Core components include Amazon VPC, subnets, route tables, gateways, security groups, and network ACLs.

What is the difference between VPC and subnet in AWS?

A VPC is the larger logically isolated virtual network that exists within an AWS Region. A subnet is a smaller IP address range within that VPC, located in a single Availability Zone.

Are AWS security groups stateful or stateless?

AWS security groups are stateful. They automatically permit tracked response traffic for allowed connections. Network ACLs are stateless and require separate rules for request and response traffic.

What is the default security group rule in AWS?

A newly created custom security group blocks all inbound traffic and allows outbound traffic by default. The VPC's built-in default security group additionally allows inbound traffic from resources associated with that same security group.

Can an EC2 instance in a private subnet access the internet?

Yes. A private EC2 instance can initiate outbound internet connections through an appropriate NAT solution without receiving unsolicited inbound internet connections. VPC endpoints can also provide private access to supported AWS services without routing through the public internet.

Does an internet gateway make an EC2 instance public?

No. Internet gateway attachment alone is insufficient. The subnet needs the appropriate route, the instance generally needs a public IP for direct IPv4 internet connectivity, and its security configuration must permit the required traffic.

How many IP addresses does AWS reserve in a subnet?

AWS reserves five IPv4 addresses in every subnet. Therefore, an IPv4  /24  subnet contains 256 total addresses but provides 251 addresses available for resource assignment.

What is the difference between a route table and a security group?

A route table determines where network traffic should go. A security group determines which traffic is permitted to reach or leave associated resources. Routing establishes the path; security rules control permissions.

Final Thoughts: The Best Cloud Network Is Designed Before the First Server Launches

You don't need to become a network engineer overnight to understand AWS networking.
Start with the fundamentals.
An IP address identifies an endpoint. CIDR defines an address range. A VPC provides the network boundary. Subnets organize resources. Route tables determine paths. Internet gateways provide internet connectivity. Security groups and network ACLs help control traffic.
When these pieces work together, cloud networking becomes much easier to reason about.
And the bigger lesson extends far beyond AWS:
Good infrastructure isn't defined by how many services you deploy. It's defined by how deliberately those services communicate.
Learn the network first. Then build the application on top of it.
Open to Cloud Ops Remote and technical writing projects.


Series: Skill Builder Digital Classroom - AWS Cloud Technical Essentials (11 articles)

  1. …
  2. 4
    AWS Networking:Amazon VPC, Subnets, Routing & Security This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article