Course contentsShow
← Security
Lesson 1825 of 3,05237. Cloud Security - Network ArchitectureFree lesson

Combining Security Groups and NACLs for Defense-in-Depth

Using NACLs for subnet-level deny rules and security groups for instance-level allow rules in layered architecture.

Combining Security Groups and NACLs for Defense-in-Depth

What you'll learn: How to layer NACLs and security groups together to create multiple defensive barriers in your cloud network architecture.

The Layered Defense Strategy

Defense-in-depth means using multiple independent security controls so that if one fails, others still protect you. In cloud networking, Network ACLs (NACLs) and security groups work at different layers and complement each other perfectly.

Think of it like a castle: NACLs are the moat around the entire fortress (subnet-level), while security groups are individual guards at each room door (instance-level).

The Division of Labor

NACLs serve as your coarse-grained subnet boundary control:

  • Block known-bad IP ranges at the subnet edge
  • Enforce broad deny rules (like blocking SSH from the internet entirely)
  • Provide stateless filtering as a first line of defense
  • Protect against port scanning and reconnaissance

Security groups handle fine-grained instance access:

  • Define specific allow rules for legitimate application traffic
  • Enable microsegmentation between instances
  • Provide stateful filtering for return traffic
  • Apply least-privilege access at the workload level

Practical Layering Pattern

A common defense-in-depth approach:

  1. NACL rule: Deny all inbound SSH (port 22) from 0.0.0.0/0 to your web subnet
  2. Security group rule: Allow inbound HTTPS (port 443) only from your load balancer's security group

This means even if someone misconfigures a security group to allow SSH, the NACL blocks it at the subnet boundary. Conversely, if a NACL is accidentally opened wide, security groups still enforce instance-level restrictions.

When to Use Which Layer

Use NACLs for: explicit denies, subnet-wide policies, and defense against broad attacks.

Use security groups for: application-specific allows, service-to-service communication, and workload isolation.

Key Takeaway: Defense-in-depth combines NACLs (subnet-level denies) with security groups (instance-level allows) to create multiple independent security barriers—if one layer is misconfigured or bypassed, the other still protects your resources.