Security Groups vs Network ACLs
Two layers of network firewall: what each one does and which one you'll actually use.
1 min read
| Security group | Network ACL (NACL) | |
|---|---|---|
| Attached to | Network interfaces (instances, databases, …) | Subnets |
| Rules | Allow only | Allow and deny |
| State | Stateful: replies allowed automatically | Stateless: must allow both directions |
| Evaluation | All rules considered | Numbered rules, first match wins |
| Default | Deny all inbound | Default NACL allows everything |
In practice
- Security groups do 95% of the work. Use one per tier (load balancer, app, database) and reference groups as sources, e.g. "database allows 5432 from the app security group".
- NACLs are a coarse extra layer, useful for blocking a known bad IP range across a whole subnet.
Watch out
If you add a custom NACL, remember it's stateless. Return traffic uses temporary high ports (1024–65535), so you must allow those outbound too, or connections will hang mysteriously.
Key takeaways
- Security groups: stateful, allow-only, attached to resources. Use them for most rules.
- NACLs: stateless, allow and deny, attached to subnets. An optional coarse layer.
- Chain security groups by referencing one from another.
Check your understanding
Pick an answer to see the explanation.
1. You need to block one specific malicious IP range from an entire subnet. Which tool can do it?