AWS Network ACLs
Stateless rule evaluation, numbered rules, explicit allow and deny, ephemeral port ranges, and differences from security groups.
Overview
Overview AWS Network Access Control Lists (NACLs) are stateless subnet-level firewalls that provide an additional layer of network security beyond Security Groups. NACLs operate at the subnet boundary and inspect each packet independently without tracking connection state.
Every subnet in a VPC is associated with exactly one NACL. The VPC's default NACL allows all inbound and outbound traffic by default. NACLs affect all instances in the subnet regardless of their individual security group configurations.
The stateless nature of NACLs has a critical practical implication: you must write rules for both the request and the response direction. For a web server receiving HTTPS on port 443, you need an inbound ALLOW rule for port 443, but you also need an outbound ALLOW rule for the ephemeral port range (1024-65535) so the server's response can exit the subnet. The client's source port is an ephemeral port chosen by the OS — typically 32768-60999 on Linux or 49152-65535 on Windows. Forgetting this ephemeral port outbound rule is the most common NACL mistake.
NACL rules are evaluated in ascending numeric order (lowest number first). The first rule that matches determines the action — ALLOW or DENY. After a matching rule is found, no further rules are evaluated. NACLs support explicit DENY rules (Security Groups do not). There is always an implicit DENY at the end (rule *) that drops all unmatched traffic.
NACLs are best used as a coarse-grained subnet boundary control and IP blocklist mechanism, complementing the fine-grained per-instance control provided by Security Groups.
Key concepts
- Stateless evaluation
- Numbered rules, first-match wins
- Explicit ALLOW and DENY
- Ephemeral ports
- Subnet association
Interview questions
- A web server in a private subnet can receive HTTPS connections but the responses never reach clients. What is the most likely cause and how do you fix it?
- How do you use NACLs to block a specific IP range that is attacking your application, and how quickly does the block take effect?
Sign up free to read the full topic
More Networking topics
Start free on Cariara · Coding problems · System design studio