AWS · Comparison
Security groups vs network ACLs
Should I filter VPC traffic with security groups, network ACLs, or both?
Decision summary
Use security groups as the main control: they attach to each network interface, are stateful (return traffic is allowed automatically), contain only allow rules, and can reference other security groups. Use network ACLs as a coarse, subnet-wide second layer, mainly to deny specific addresses or ranges, remembering that they are stateless, so return traffic (ephemeral ports) must be allowed explicitly.
Best fit for each option
Security groups
Per-resource access control, allowing only what each tier needs, and referencing other security groups instead of IP ranges.
Network ACLs
Subnet-wide guardrails and explicit deny rules, such as blocking a malicious IP range quickly.
Side by side
| Security groups | Network ACLs | |
|---|---|---|
| Best for | Per network interface allow rules | Subnet-wide allow and deny rules |
| Security | Stateful; allow only; can reference other groups | Stateless; allow and deny; evaluated in number order |
| Limits | 60 inbound and 60 outbound rules by default | 20 rules per direction by default |
| Operational complexity | Simple; return traffic automatic | Must allow ephemeral ports for responses |
| Cost | No charge | No charge |
Scaling and topology
Limits and constraints
| Item | Value | Context | Source |
|---|---|---|---|
| Rules per security group | 60 inbound and 60 outbound Can be raised with a quota request |
Source checked |
|
| Rules per network ACL | 20 per direction Can be raised with a quota request |
Can be raised to 40 inbound and 40 outbound. | Source checked |
Quotas and limits change. Check the linked source before designing around a number.
When to avoid each option
Security groups
- Blocking a specific IP address: security groups cannot deny.
Network ACLs
- Fine-grained per-instance rules: they apply to the whole subnet and need return-traffic rules.
Example scenarios
| Situation | Choose | Why |
|---|---|---|
| Allow only the load balancer to reach the app servers. | Security groups | Reference the load balancer's security group. |
| Block one attacking IP range immediately for a whole subnet. | Network ACLs | Network ACLs support deny rules. |
| A response is blocked even though inbound is allowed. | Network ACLs | Stateless: add an outbound rule for ephemeral ports. |
Exam cues
- Stateful vs stateless: security groups vs network ACLs.
- Deny a specific IP: network ACL (or WAF for HTTP).
- Rule order: network ACL rules by number, lowest first; security groups evaluate all rules.
Related
Courses and lessons
- Security groups vs network ACLs · AWS Solutions Architect – Associate (SAA-C03) · Members
Services, comparisons and patterns
- Amazon VPC · Service
- AWS Network Firewall · Service
- AWS WAF · Service
Sources
Independent study material, not affiliated with or endorsed by Amazon Web Services.