Security Group vs NACL: which one filters what?
A security group is a stateful filter attached to a network interface; a network ACL is a stateless filter at the subnet boundary. The two layers complement each other rather than replace each other.
Compare by characteristic
| Characteristic | Security group | Network ACL |
|---|---|---|
| Where it applies | The network interface of a resource such as an EC2 instance | Every subnet it is associated with |
| Connection state | Stateful: return traffic is allowed automatically | Stateless: rules are needed for both directions |
| Rule types | Allow rules only | Both allow and deny rules |
| How rules are evaluated | All rules are evaluated | Rules are evaluated in number order and the first match applies |
When to use which
Use security groups as the primary control for each application, for example letting only the web tier reach the database tier on the needed port. Add a network ACL when you must explicitly block an address range at the subnet level, because only network ACLs support deny rules. Because network ACLs are stateless, remember to allow the ephemeral ports used by return traffic.
- A security group denies inbound traffic that is not explicitly allowed.
- The default network ACL of a VPC allows all traffic; a newly created custom network ACL denies everything until you add rules.
Check your understanding
If a scenario says “block a specific IP address”, think network ACL because a deny rule is needed. If it says “only the application tier may connect to the database”, think security group, often referencing another security group as the source.
References
Use AWS documentation to check current features and limits. Cloud Quest is an independent learning project and does not guarantee exam outcomes.