AWS Security Group vs Network ACL (NACL): Stateful vs Stateless Explained Visually
Security Groups and Network ACLs both filter VPC traffic, but they operate at different layers with completely different state models. Watching a real return packet get blocked by a missing NACL ephemeral port rule makes the difference click permanently.
Security Groups = Stateful (ENI Level)
Return traffic is automatically allowed via connection tracking regardless of outbound rules. Supports Allow rules only.
Network ACLs = Stateless (Subnet Level)
Return traffic must be explicitly permitted (TCP ports 1024–65535). Supports both Allow and Deny rules evaluated in numerical order.
Explicit IP Blocking
Need to block a single malicious IP address inside a VPC? Use a NACL Deny rule with a lower rule number (e.g., Rule #50) before Allow All (#100).
Side-by-Side: AWS Security Group vs Network ACL (SAA-C03 Cheatsheet)
| Step / Dimension | Component | Technical Behavior |
|---|---|---|
| Scope | Instance / ENI level | Subnet boundary level (applies to all instances in subnet) |
| Statefulness | Stateful (return traffic auto-allowed) | Stateless (must explicitly allow return ephemeral ports 1024-65535) |
| Rule Types | Allow rules only (implicit deny) | Both Allow and Deny rules |
| Evaluation Order | All rules evaluated together before deciding | Strict ascending rule number order (lowest number wins first) |
Terraform NACL Rule Allowing Return Ephemeral Traffic
resource "aws_network_acl_rule" "allow_ephemeral_egress" {
network_acl_id = aws_network_acl.public.id
rule_number = 110
egress = true
protocol = "tcp"
rule_action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 1024
to_port = 65535
}
Frequently Asked Questions
Why do AWS Network ACLs need ephemeral ports 1024-65535?
Because NACLs are stateless. When a browser connects to your web server on port 443, the browser uses a random high source port (1024-65535). The NACL outbound rule must explicitly allow those ephemeral ports for the HTTP response to leave the subnet.
Which AWS VPC firewall can block a specific attacker IP address?
A Network ACL (or AWS WAF at Layer 7). Security Groups only support Allow rules and cannot explicitly deny a single IP address.
Can I simulate Security Group vs NACL packet drops visually?
Yes — CloudTracer runs a stateful ConntrackTable for Security Groups and a stateless numerical rule evaluator for NACLs so you can see the exact rule that dropped a packet.