Course contentsShow
← Cloud and Infrastructure
Lesson 228 of 2,9894. Cloud Networking BasicsFree lesson

Network ACL vs Security Group Comparison

Understand the differences, use cases, and interaction between stateless NACLs and stateful security groups.

Network ACL vs Security Group Comparison

What you'll learn: You'll understand the key differences between stateless Network ACLs and stateful Security Groups, and when to use each for cloud network security.

The Tale of Two Security Layers

Think of Security Groups as a personal bodyguard and Network ACLs as airport security checkpoints. Your bodyguard (Security Group) remembers you and automatically lets you back through after you leave—it's stateful. Airport security (NACL) checks everyone entering and leaving separately, with no memory of who passed through before—it's stateless.

Security Groups: Stateful and Instance-Level

Security Groups operate at the instance/resource level. When you allow an inbound connection on port 443, the return traffic is automatically allowed—no explicit outbound rule needed. The connection state is tracked. You can only create allow rules, never deny rules. If there's no matching allow rule, traffic is implicitly denied.

Network ACLs: Stateless and Subnet-Level

NACLs operate at the subnet boundary. They evaluate traffic entering and leaving the subnet independently. If you allow inbound traffic on port 443, you must also create an outbound rule for the ephemeral ports (typically 1024-65535) to allow response traffic back out. NACLs support both allow and deny rules, evaluated in numbered order (lowest first).

When They Work Together

Both layers apply to traffic: Security Groups protect individual resources, while NACLs provide subnet-level boundaries. A packet must pass the NACL check (entering the subnet), then the Security Group check (reaching the instance), then NACL again (leaving the subnet).

Use Security Groups for granular, resource-specific rules. Use NACLs for broad subnet-level policies or when you need explicit deny rules.

Key Takeaway: Security Groups are stateful, instance-level firewalls that only allow; Network ACLs are stateless, subnet-level firewalls that support both allow and deny rules—together they provide defense in depth.