Security Groups vs Network ACLs: Fundamental Differences
You'll learn the key distinctions between Security Groups and Network ACLs—two complementary but fundamentally different network security controls in cloud environments.
Core Concept
Think of Security Groups as personal bodyguards that follow individual resources around, while Network ACLs (Access Control Lists) are like checkpoint gates at subnet borders. Both control network traffic, but they operate at different layers with different characteristics.
Stateful vs Stateless
Security Groups are stateful: when you allow inbound traffic, the response is automatically allowed back out—no explicit outbound rule needed. Like a two-way conversation where replies are automatically permitted.
Network ACLs are stateless: you must explicitly allow both inbound and outbound traffic for each connection. If you allow HTTP requests in, you must separately allow the response traffic out (typically ephemeral ports 1024-65535).
Scope and Attachment
Security Groups attach to individual instances or resources (EC2 instances, RDS databases, load balancers). They're resource-specific firewalls.
Network ACLs apply to entire subnets. Every resource in that subnet is governed by the NACL, making it a broader boundary control.
Evaluation Order
Security Groups: All rules are evaluated together; if any rule allows the traffic, it passes. Rules are implicitly deny by default.
Network ACLs: Rules are processed in numerical order (lowest first). The first matching rule wins—subsequent rules are ignored. Includes explicit deny rules.
When to Use Each
Use Security Groups as your primary defense—granular, instance-level control. Use Network ACLs as a second layer for subnet-wide policies, explicit denies (like blocking known malicious IPs), or compliance requirements demanding stateless controls.
Key Takeaway: Security Groups provide stateful, resource-level filtering ideal for allow-listing, while Network ACLs offer stateless, subnet-level filtering with ordered rule evaluation—use both together for defense in depth.