Understand the difference between Security Groups and Network ACLs (NACL) in AWS with real-world examples, use cases, and best practices for secure VPC design.
When working with AWS VPC, one of the most common interview questions and real-world challenges is understanding the difference between Security Groups and Network ACLs (NACLs).
Both are used to control traffic, but they operate at different levels and behave very differently.
If you misconfigure these:
Understanding both is critical for secure cloud architecture
A Security Group acts as a firewall at the instance level.
If you allow inbound traffic:
Port 80 β Allowed
π Response traffic is automatically allowed, even if outbound rules donβt explicitly allow it.
A Network ACL acts as a firewall at the subnet level.
If you allow inbound:
Port 80 β Allowed
π You must ALSO explicitly allow outbound response traffic Otherwise β request fails β
| Feature | Security Group | NACL |
|---|---|---|
| Level | Instance level | Subnet level |
| Type | Stateful | Stateless |
| Rules | Allow only | Allow + Deny |
| Evaluation | All rules evaluated | Rules processed in order |
| Default behavior | Deny all inbound | Allow all (default NACL) |
Internet
|
[NACL]
|
[Subnet]
|
[Security Group]
|
[EC2 Instance]
π Traffic must pass through:
Letβs say:
π This creates layered security
0.0.0.0/0 everywhere β0.0.0.0/0)π Together, they provide defense in depth
Understanding the difference between Security Groups and NACL is essential for:
Once you master this, VPC security becomes much easier to manage.
