AWS Builder Center
Security Groups vs Network ACLs: The AWS Firewall Rules That Finally Made Sense

Security Groups vs Network ACLs: The AWS Firewall Rules That Finally Made Sense

A beginner-friendly comparison of AWS Security Groups and Network ACLs, including how they control traffic, where they operate, and when to use each one.

πŸ” Security Groups vs Network ACLs: The AWS Firewall Rules That Finally Made Sense

When I started learning AWS networking, two terms kept appearing:
Security Groups
Network ACLs
Both control network traffic.
So naturally, I wondered:
Why does AWS need two different security controls?
After learning how they work, the difference became much clearer.
The easiest way I now remember it is:
Security Groups protect resources. Network ACLs protect subnets.
Let's break that down.

πŸ—οΈ First, Where Do They Sit?

Imagine this simple architecture:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
🌍 Internet
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ VPC β”‚
β”‚ β”‚
β”‚ Public Subnetβ”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ EC2 β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β–² β”‚
β”‚ β”‚ β”‚
β”‚ Security β”‚
β”‚ Group β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
The Security Group is associated with the resource, such as an EC2 instance.
A Network ACL operates at the subnet level.
So the traffic path can be thought of as:
1
2
3
4
5
6
7
8
9
10
11
12
13
Internet
β”‚
β–Ό
Network ACL
β”‚
β–Ό
Subnet
β”‚
β–Ό
Security Group
β”‚
β–Ό
EC2
This distinction is fundamental.

πŸ›‘οΈ What Is a Security Group?

A Security Group acts like a virtual firewall for AWS resources such as EC2 instances.
For example, I might create rules like:
1
2
3
4
5
6
7
8
9
Inbound Rules

HTTPS
Port: 443
Source: 0.0.0.0/0

SSH
Port: 22
Source: My trusted IP
This means:
  • HTTPS traffic can reach the instance.
  • SSH is restricted to my trusted IP.
  • Other inbound traffic isn't allowed by the security group's inbound rules.

πŸ”„ Security Groups Are Stateful

This is one of the most important differences.
Security Groups are stateful.
Imagine my EC2 instance receives a request:
1
2
3
4
5
6
7
8
9
Client
β”‚
β”‚ HTTPS Request
β–Ό
EC2
β”‚
β”‚ Response
β–Ό
Client
If the inbound request is allowed by the Security Group, the response traffic is automatically allowed as part of that established connection.
I don't need to create a separate rule specifically for the response traffic.
That's what stateful means in this context.

🚧 What Is a Network ACL?

A Network Access Control List (NACL) operates at the subnet level.
Instead of protecting one specific EC2 instance, it controls traffic entering or leaving a subnet.
For example:
1
2
3
4
5
6
7
8
9
10
11
VPC
β”‚
β”œβ”€β”€ Public Subnet
β”‚ β”‚
β”‚ └── NACL
β”‚ β”‚
β”‚ └── EC2
β”‚
└── Private Subnet
β”‚
└── NACL
A subnet has an associated Network ACL.
This provides another layer of network control.

πŸ”’ NACL Rules Use Rule Numbers

NACL rules are evaluated in order.
For example:
1
2
3
4
5
6
7
8
9
10
Rule #100
Allow TCP 443
Source: 0.0.0.0/0

Rule #200
Allow TCP 80
Source: 0.0.0.0/0

Rule #*
Deny everything else
AWS evaluates the rules starting with the lowest rule number.
The first matching rule is applied.
This means the order of NACL rules matters.

πŸ”„ NACLs Are Stateless

This is another major difference.
Network ACLs are stateless.
If I allow inbound traffic, I also need to consider the corresponding outbound traffic.
For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Client
β”‚
β”‚ Request
β–Ό
NACL
β”‚
β–Ό
EC2
β”‚
β”‚ Response
β–Ό
NACL
β”‚
β–Ό
Client
The inbound and outbound traffic are evaluated separately.
This is different from Security Groups.

βš”οΈ Security Group vs NACL

Here's the comparison that helped me remember the difference:
FeatureSecurity GroupNetwork ACL
Operates atResource levelSubnet level
Statefulβœ… Yes❌ No
Supports explicit deny❌ Noβœ… Yes
RulesAllow rulesAllow + Deny
Rule orderDoesn't use numbered evaluation orderLowest number evaluated first
ControlsTraffic to/from associated resourcesTraffic entering/leaving subnet
Common useProtect EC2 and other resourcesAdditional subnet-level traffic control

🧠 A Simple Analogy

I found this analogy useful.
Imagine an apartment building.

🏒 Network ACL = Building security

The building security decides:
"Who is allowed into this part of the building?"
It operates at a broader level.

πŸšͺ Security Group = Apartment door

The apartment door controls:
"Who can access this particular apartment?"
It's much more specific.
So:
1
2
3
4
5
6
7
8
9
10
Building Security
β”‚
β–Ό
Subnet
β”‚
β–Ό
Apartment Door
β”‚
β–Ό
Resource
This isn't a perfect technical analogy, but it helped me understand the different scopes.

🌐 Real-World Example

Suppose I'm building a web application.
My architecture looks like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
🌍 Internet
β”‚
β–Ό
Load Balancer
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Public Subnet β”‚
β”‚ β”‚
β”‚ Network ACL β”‚
β”‚ β”‚ β”‚
β”‚ β–Ό β”‚
β”‚ Load Balancer β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Private Subnet β”‚
β”‚ β”‚
β”‚ Network ACL β”‚
β”‚ β”‚ β”‚
β”‚ β–Ό β”‚
β”‚ EC2 β”‚
β”‚ Security Group β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
Database
I can use Network ACLs as a subnet-level control and Security Groups as a more specific resource-level control.

πŸ”— Security Groups Can Reference Other Security Groups

Another useful feature is that Security Groups can reference other Security Groups in certain AWS networking scenarios.
For example:
1
2
3
4
5
6
7
8
9
Load Balancer SG
β”‚
β”‚ allows HTTPS
β–Ό
Application SG
β”‚
β”‚ allows database traffic
β–Ό
Database SG
Instead of relying entirely on IP addresses, I can express relationships between application components.
For example:
Allow the database to receive traffic from the application servers' Security Group.
This makes large architectures easier to manage.

⚠️ Common Beginner Mistakes

❌ Mistake 1: Thinking Security Groups support explicit deny rules

They don't.
Security Groups use allow rules, and traffic that isn't allowed is denied.

❌ Mistake 2: Forgetting that NACLs are stateless

Inbound and outbound traffic are evaluated independently.

❌ Mistake 3: Thinking a public subnet automatically means every resource is publicly accessible

It doesn't.
Routing, IP addressing, Security Groups, and other configuration still matter.

❌ Mistake 4: Opening SSH to the entire internet unnecessarily

A rule such as:
1
2
Port: 22
Source: 0.0.0.0/0
allows SSH attempts from anywhere.
For administrative access, a narrower trusted source is generally preferable when practical.

❌ Mistake 5: Using complicated NACL rules without understanding the traffic flow

Because NACLs are stateless and rule ordering matters, troubleshooting them can become difficult if the rules aren't carefully designed.

πŸ” How I Think About Troubleshooting Now

If an EC2 instance can't communicate with something else, I don't immediately blame the application.
I walk through the network:
1
2
3
4
5
6
7
8
9
1. Is the resource in the correct subnet?
↓
2. What does the route table say?
↓
3. Does the Network ACL allow the traffic?
↓
4. Does the Security Group allow the traffic?
↓
5. Is the resource configured correctly?
This approach gives me a much better way to troubleshoot AWS networking.

🎯 My Mental Model

After learning both concepts, I remember them like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
VPC
β”‚
β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
β”‚ Subnet β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
β”‚
Network ACL
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Resource β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
β”‚
Security Group
Network ACL β†’ subnet-level control
Security Group β†’ resource-level control
And the biggest difference:
Security Groups are stateful and allow-based, while Network ACLs are stateless and support both allow and deny rules.

πŸš€ Final Takeaway

AWS networking initially looked like a collection of unrelated terms:
VPC β†’ Subnet β†’ Route Table β†’ Internet Gateway β†’ Security Group β†’ NACL
But once I started thinking about where traffic enters, where it goes, and which layer controls it, the architecture became much easier to understand.
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