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 groupNetwork ACL (NACL)
Attached toNetwork interfaces (instances, databases, …)Subnets
RulesAllow onlyAllow and deny
StateStateful: replies allowed automaticallyStateless: must allow both directions
EvaluationAll rules consideredNumbered rules, first match wins
DefaultDeny all inboundDefault 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. 1. You need to block one specific malicious IP range from an entire subnet. Which tool can do it?