Bird
Raised Fist0
AWScloud~5 mins

Network ACLs overview in AWS - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Network ACLs control traffic in and out of subnets in a virtual network. They help protect your cloud resources by allowing or blocking specific traffic at the subnet level.
When you want to block certain IP addresses from accessing your subnet.
When you need an extra layer of security beyond security groups.
When you want to control traffic flow between different subnets.
When you want to allow or deny traffic based on protocol or port number.
When you want to log traffic that is allowed or denied for auditing.
Commands
This command creates a new Network ACL in the specified VPC to start controlling subnet traffic.
Terminal
aws ec2 create-network-acl --vpc-id vpc-0abc1234def567890
Expected OutputExpected
{ "NetworkAcl": { "NetworkAclId": "acl-0a1b2c3d4e5f6g7h8", "VpcId": "vpc-0abc1234def567890", "IsDefault": false, "Entries": [], "Associations": [], "Tags": [] } }
--vpc-id - Specifies the VPC where the Network ACL will be created
This command adds a rule to deny outbound TCP traffic on port 80 in the Network ACL.
Terminal
aws ec2 create-network-acl-entry --network-acl-id acl-0a1b2c3d4e5f6g7h8 --rule-number 100 --protocol 6 --port-range From=80,To=80 --egress --rule-action deny
Expected OutputExpected
No output (command runs silently)
--network-acl-id - Specifies which Network ACL to modify
--rule-number - Defines the priority of the rule; lower numbers have higher priority
--egress - Indicates this rule applies to outbound traffic
--rule-action - Sets whether to allow or deny matching traffic
This command shows the details of the Network ACL including its rules to verify the configuration.
Terminal
aws ec2 describe-network-acls --network-acl-ids acl-0a1b2c3d4e5f6g7h8
Expected OutputExpected
{ "NetworkAcls": [ { "NetworkAclId": "acl-0a1b2c3d4e5f6g7h8", "VpcId": "vpc-0abc1234def567890", "Entries": [ { "RuleNumber": 100, "Protocol": "6", "RuleAction": "deny", "Egress": true, "PortRange": { "From": 80, "To": 80 }, "CidrBlock": "0.0.0.0/0", "Ipv6CidrBlock": null } ], "Associations": [], "IsDefault": false } ] }
--network-acl-ids - Filters the output to show only the specified Network ACL
This command links the Network ACL to a specific subnet so its rules control traffic for that subnet.
Terminal
aws ec2 associate-network-acl --network-acl-id acl-0a1b2c3d4e5f6g7h8 --subnet-id subnet-0123456789abcdef0
Expected OutputExpected
{ "AssociationId": "aclassoc-1234abcd5678efgh9" }
--network-acl-id - Specifies the Network ACL to associate
--subnet-id - Specifies the subnet to apply the Network ACL to
Key Concept

If you remember nothing else from this pattern, remember: Network ACLs control traffic at the subnet level by allowing or denying rules in order of rule number.

Common Mistakes
Not specifying the correct VPC ID when creating a Network ACL.
The Network ACL will be created in the wrong VPC or the command will fail.
Always double-check and use the correct VPC ID for your environment.
Using the same rule number for multiple rules in a Network ACL.
Rule numbers must be unique; duplicate numbers cause errors or unexpected behavior.
Assign unique rule numbers to each rule, typically in increments of 100.
Forgetting to associate the Network ACL with a subnet after creating it.
Without association, the Network ACL rules do not apply to any subnet.
Always run the associate-network-acl command to link the ACL to the desired subnet.
Summary
Create a Network ACL in your VPC to start controlling subnet traffic.
Add rules with unique rule numbers to allow or deny specific traffic.
Associate the Network ACL with a subnet to enforce the rules on that subnet.
Verify your Network ACL and its rules using the describe command.

Practice

(1/5)
1. What is the primary purpose of a Network ACL in AWS?
easy
A. To monitor application performance
B. To manage user permissions for AWS services
C. To store data securely in the cloud
D. To control inbound and outbound traffic at the subnet level

Solution

  1. Step 1: Understand Network ACL function

    Network ACLs act as a firewall controlling traffic entering and leaving subnets.
  2. Step 2: Identify correct purpose

    They specifically control inbound and outbound traffic at the subnet level, not user permissions or data storage.
  3. Final Answer:

    To control inbound and outbound traffic at the subnet level -> Option D
  4. Quick Check:

    Network ACL = subnet traffic control [OK]
Hint: Network ACLs control subnet traffic, not users or data [OK]
Common Mistakes:
  • Confusing Network ACLs with IAM permissions
  • Thinking Network ACLs store data
  • Assuming Network ACLs monitor performance
2. Which of the following is the correct way to define a rule in a Network ACL?
easy
A. User name, password, access level, allow or deny
B. Instance ID, security group, IP address, allow or deny
C. Rule number, protocol, port range, source/destination, allow or deny
D. Subnet ID, route table, gateway, allow or deny

Solution

  1. Step 1: Recall Network ACL rule components

    Network ACL rules include a rule number, protocol, port range, source or destination IP, and action (allow or deny).
  2. Step 2: Match correct option

    Rule number, protocol, port range, source/destination, allow or deny lists these components correctly; other options mention unrelated elements like user credentials or instance IDs.
  3. Final Answer:

    Rule number, protocol, port range, source/destination, allow or deny -> Option C
  4. Quick Check:

    Network ACL rule = numbered protocol and ports [OK]
Hint: Network ACL rules use numbers, protocols, ports, and allow/deny [OK]
Common Mistakes:
  • Mixing user credentials with ACL rules
  • Confusing security groups with ACL rules
  • Using subnet or route info as rule components
3. Given a Network ACL with the following rules:
Rule 100: Allow TCP port 80 from 0.0.0.0/0
Rule 110: Deny all traffic
What happens to an incoming TCP request on port 80 from IP 192.168.1.1?
medium
A. The request is allowed because rule 100 permits it
B. The request is denied because rule 110 denies all traffic
C. The request is ignored due to missing rule for port 80
D. The request causes an error in the Network ACL

Solution

  1. Step 1: Understand rule evaluation order

    Network ACLs evaluate rules by ascending rule number. Rule 100 is checked before 110.
  2. Step 2: Apply rules to the request

    Rule 100 allows TCP port 80 from any IP, so the request from 192.168.1.1 is allowed before rule 110 denies all.
  3. Final Answer:

    The request is allowed because rule 100 permits it -> Option A
  4. Quick Check:

    Lower rule number allow overrides higher deny [OK]
Hint: Rules checked in order; first match decides allow or deny [OK]
Common Mistakes:
  • Assuming deny all overrides allow rules
  • Ignoring rule number order
  • Thinking missing rules cause errors
4. You created a Network ACL with these rules:
Rule 100: Allow inbound TCP port 22 from 10.0.0.0/16
Rule 110: Deny all inbound traffic
But SSH connections from 10.0.1.5 are failing. What is the likely problem?
medium
A. The Network ACL is stateless and missing an outbound allow rule for port 22
B. The security group attached to the instance denies SSH
C. The subnet does not have a route to the internet
D. The IP 10.0.1.5 is outside the allowed range

Solution

  1. Step 1: Recall Network ACL stateless behavior

    Network ACLs are stateless, so return traffic must be explicitly allowed by outbound rules.
  2. Step 2: Analyze rules and failure cause

    Inbound SSH is allowed, but if outbound port 22 is denied, the response cannot return, causing failure.
  3. Final Answer:

    The Network ACL is stateless and missing an outbound allow rule for port 22 -> Option A
  4. Quick Check:

    Stateless ACLs need inbound and outbound rules [OK]
Hint: Stateless ACLs need both inbound and outbound rules [OK]
Common Mistakes:
  • Assuming ACLs are stateful like security groups
  • Ignoring outbound rules for return traffic
  • Mistaking IP range or subnet routing as cause
5. You want to block all HTTP traffic (port 80) to a subnet except from a specific IP 203.0.113.5 using Network ACLs. Which rule set achieves this?
hard
A. Rule 100: Deny TCP port 80 from 0.0.0.0/0
Rule 110: Allow TCP port 80 from 203.0.113.5
Rule 120: Allow all other traffic
B. Rule 100: Allow TCP port 80 from 203.0.113.5
Rule 110: Deny TCP port 80 from 0.0.0.0/0
Rule 120: Allow all other traffic
C. Rule 100: Allow all traffic
Rule 110: Deny TCP port 80 from 0.0.0.0/0
D. Rule 100: Deny all traffic
Rule 110: Allow TCP port 80 from 203.0.113.5

Solution

  1. Step 1: Understand rule evaluation order

    Network ACLs evaluate rules by ascending number; first matching rule applies.
  2. Step 2: Analyze rules for desired effect

    Rule 100 allows port 80 only from 203.0.113.5. Rule 110 denies port 80 from all others. Rule 120 allows other traffic.
  3. Step 3: Confirm correct blocking and allowing

    This setup blocks HTTP except from the specific IP, matching the requirement.
  4. Final Answer:

    Rule 100: Allow TCP port 80 from 203.0.113.5; Rule 110: Deny TCP port 80 from 0.0.0.0/0; Rule 120: Allow all other traffic -> Option B
  5. Quick Check:

    Allow specific IP first, then deny others [OK]
Hint: Allow specific IP first, then deny all others [OK]
Common Mistakes:
  • Placing deny before allow for specific IP
  • Not including allow for other traffic
  • Assuming ACLs are stateful