Process Flow - Security groups vs NACLs decision
Start: Incoming Traffic
Check NACL Rules
Check SG Rules
End
Traffic first passes through NACL rules, then security group rules. Both must allow traffic for it to reach the resource.
NACL: Allow inbound port 80 SG: Allow inbound port 80 Traffic arrives on port 80 Check NACL -> Allowed Check SG -> Allowed Traffic reaches server
| Step | Traffic Port | NACL Rule Check | NACL Result | SG Rule Check | SG Result | Final Outcome |
|---|---|---|---|---|---|---|
| 1 | 80 | Allow inbound 80 | Allowed | Allow inbound 80 | Allowed | Traffic reaches server |
| 2 | 22 | Deny inbound 22 | Denied | Allow inbound 22 | Allowed | Traffic blocked by NACL |
| 3 | 443 | Allow inbound 443 | Allowed | Deny inbound 443 | Denied | Traffic blocked by SG |
| 4 | 8080 | No rule for 8080 | Denied (default deny) | Allow inbound 8080 | Allowed | Traffic blocked by NACL |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 |
|---|---|---|---|---|---|
| Traffic Port | None | 80 | 22 | 443 | 8080 |
| NACL Result | None | Allowed | Denied | Allowed | Denied |
| SG Result | None | Allowed | Allowed | Denied | Allowed |
| Final Outcome | None | Reach Server | Blocked | Blocked | Blocked |
Security groups and NACLs control traffic in AWS. NACLs act as a firewall at subnet level, evaluated first. Security groups act at instance level, evaluated second. Traffic must be allowed by both to reach the resource. NACLs have stateless rules; security groups are stateful. Default deny applies if no rule matches in NACL.