How Network ACLs Filter Subnets
Learn the stateless rules that guard an entire subnet.
How Network ACLs Filter Subnets is a free AWS Security Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Subnet Firewall
A network ACL (NACL) is a firewall that operates at the subnet boundary. Every packet entering or leaving a subnet is evaluated against the NACL associated with that subnet, regardless of which instance sent or received it. It is the second layer of network defense alongside security groups.
Numbered, Ordered Rules
NACL rules are numbered and evaluated in ascending order. AWS checks rule 100 before 200, and the first matching rule wins, stopping evaluation. This ordering is the opposite of security groups, where all rules combine with no priority. Leave gaps (100, 200, 300) so you can insert rules later.
Allow and Deny
Unlike security groups, NACLs support both allow and deny rules. This lets you block a specific malicious IP or CIDR range outright, something a security group cannot do. A common pattern is denying a known bad source at a low rule number before broader allow rules.
aws ec2 create-network-acl-entry \
--network-acl-id acl-0abc123 \
--rule-number 90 --protocol -1 \
--cidr-block 198.51.100.0/24 \
--rule-action deny --ingressSeparate Inbound and Outbound
Each NACL has independent inbound and outbound rule sets, each with its own numbering. Because NACLs are stateless, you must explicitly handle both directions of every conversation, including the return traffic.
The Default NACL
The default NACL created with a VPC allows all inbound and all outbound traffic, so it is effectively transparent. Any custom NACL you create starts by denying all traffic in both directions until you add allow rules. Subnets without an explicit association use the default NACL.
One NACL per Subnet
A subnet can be associated with exactly one NACL at a time, though one NACL can guard many subnets. This is the reverse of security groups, where a resource can have many. NACLs apply broadly to everything in the subnet, making them a coarse control.
The Asterisk Rule
Every NACL ends with an implicit * rule that denies anything not matched by a numbered rule. You cannot edit or remove it. If a packet falls through all your numbered rules, the asterisk denies it, so forgetting a needed allow rule silently breaks traffic.
Ephemeral Ports
Because NACLs are stateless, return traffic uses ephemeral ports (typically 1024–65535 for Linux, 49152–65535 for Windows). You must add outbound or inbound allow rules covering this range, or responses get dropped. This is the classic NACL gotcha the exam loves to test.
Blocking a Bad Actor
NACLs shine when you must block an IP range across a whole subnet quickly during an incident. A deny rule at a low number stops that source from reaching any instance. Security groups cannot do this because they only allow, making NACLs valuable for rapid containment.
Coarse but Fast
Treat NACLs as a blunt, subnet-wide instrument and security groups as the fine, per-resource tool. Most architectures rely primarily on security groups and use NACLs sparingly for explicit deny scenarios, keeping the default permissive unless a specific block is needed.
Logging the Effect
NACL decisions, like SG decisions, are observed through VPC Flow Logs, which show the final accept or reject for each flow. Flow Logs do not say which control made the decision, so understanding rule order helps you reason about why a packet was rejected.
Quick Check
Test your understanding of NACL evaluation.
Recap
Network ACLs are stateless, ordered firewalls at the subnet boundary supporting both allow and deny. Rules are numbered and the first match wins, ending with an uneditable deny-all asterisk. Custom NACLs deny everything until you add rules. Because they are stateless you must allow ephemeral ports for return traffic. Use them for coarse, fast subnet-wide blocks of bad IPs.
Frequently asked questions
Is the “How Network ACLs Filter Subnets” lesson free?
Yes — the full text of “How Network ACLs Filter Subnets” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “How Network ACLs Filter Subnets”?
Learn the stateless rules that guard an entire subnet. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Security Academy?
No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “How Network ACLs Filter Subnets” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Security Academy lesson?
Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- How Security Groups Filter Traffic
- How Network ACLs Filter Subnets
- Stateful versus Stateless Behavior
- Layering Both for Defense in Depth