AP Cybersecurity · Study guide

Firewall Access Control Lists

AP® Cybersecurity · Unit 3 · Network Security, Firewalls & Detection

Firewall Access Control Lists

How a firewall uses an ordered list of rules to permit or deny traffic, and why the first matching rule decides.

1What an ACL is

A firewall does not decide on its own what to allow. Network administrators write a set of rules called an access control list (ACL), and the firewall uses it to permit or deny inbound and outbound traffic. Think of it as the guest list and instructions at a door: who gets in, who gets turned away, checked in a fixed order.

2The parts of a rule

A typical ACL rule specifies three things:

  • Direction: inbound (coming into the network) or outbound (leaving it).
  • Criteria to filter by: IP addresses (single addresses or ranges), logical ports, services, or applications.
  • Action: permit (allow) or deny.
Figure 1. Every rule names a direction, what to match (address, port, service, or application), and what to do (permit or deny).

Address ranges are often written like 10.10.1.0/24, meaning every address from 10.10.1.0 to 10.10.1.255. ALL means any address, port, or protocol.

3Order matters: first match wins

ACL rules are checked in order, top to bottom, and the first rule that matches the packet is applied. Later rules are not consulted for that packet. Most firewalls end with a rule (or a built-in default) that denies anything not explicitly allowed.

Example ACL
Rule 1: DENY inbound TCP ALL from 198.51.100.0/24
Rule 2: ALLOW inbound TCP port 443 from ALL
Rule 3: ALLOW inbound TCP port 22 from 10.10.1.0/24
Rule 4: DENY inbound ALL ALL from ALL
Figure 2. Because the block on 198.51.100.0/24 sits above the rule allowing port 443, addresses in that range are denied even when visiting the website.

4Reading an ACL

To decide what happens to a packet, go down the list and stop at the first rule where every part matches: direction, protocol, port, and source.

PacketDescriptionFirst matching ruleResult
Avisitor loading the website: inbound TCP port 443 from 203.0.113.8Rule 2ALLOW
Bwebsite request from a blocked range: inbound TCP port 443 from 198.51.100.77Rule 1DENY
Cadmin logging in from the staff subnet: inbound TCP port 22 from 10.10.1.15Rule 3ALLOW
Dlogin attempt from the internet: inbound TCP port 22 from 203.0.113.8Rule 4DENY
Eunrequested DNS traffic: inbound UDP port 53 from 203.0.113.8Rule 4DENY
The key idea

An ACL is read top to bottom, and the first full match decides. To predict a firewall's behavior, check every part of each rule against the packet and stop at the first one that fits.

5Worked examples

Worked Example 1 Trace a packet

The admin login

Using the example ACL, what happens to an inbound TCP packet to port 22 from 10.10.1.15?

  1. 1
    Rule 1: denies TCP from 198.51.100.0/24. The source 10.10.1.15 is not in that range: no match.
  2. 2
    Rule 2: allows TCP port 443. The port is 22: no match.
  3. 3
    Rule 3: allows TCP port 22 from 10.10.1.0/24. Direction, protocol, port, and source all match.
Answer: Allowed by Rule 3.
Worked Example 2 Trace a packet

SSH from the internet

What happens to an inbound TCP packet to port 22 from 203.0.113.8?

  1. 1
    Rule 1: source not in 198.51.100.0/24: no match.
  2. 2
    Rule 2: port 22, not 443: no match.
  3. 3
    Rule 3: port 22 matches, but the source is not in 10.10.1.0/24: no match.
  4. 4
    Rule 4: denies all inbound traffic: match.
Answer: Denied by Rule 4. Remote login is only allowed from the staff subnet.
Worked Example 3 Order changes the result

Swap rules 1 and 2

If Rules 1 and 2 swapped places, what would happen to a website request (TCP port 443) from 198.51.100.77?

  1. 1
    New Rule 1 would be “ALLOW inbound TCP port 443 from ALL.”
  2. 2
    The packet is inbound TCP port 443 from an address in ALL: it matches the new Rule 1.
  3. 3
    First match wins, so it is allowed; the deny rule for 198.51.100.0/24 is never reached.
Answer: It would be allowed. Moving a broad allow rule above a specific deny rule cancels the deny without warning.
Worked Example 4 Read the parts

Direction matters

A rule reads DENY outbound TCP port 25 from ALL. What does it block, and why might an organization want it?

  1. 1
    Direction: outbound, traffic leaving the network.
  2. 2
    Criteria: TCP port 25, the port used for sending email between mail servers.
  3. 3
    Effect: computers inside cannot send email directly to outside mail servers.
  4. 4
    Why: if a computer is infected with spam-sending malware, it cannot blast out email; legitimate mail goes through the organization's own mail server instead.
Answer: It blocks outbound mail-server traffic from internal computers, a common defense against infected machines sending spam.

6Common mistakes

Common Mistake 1 · Reading all the rules and “combining” them

The firewall stops at the first match. A later rule never overrides an earlier one for that packet.

Common Mistake 2 · Matching only part of a rule

A rule matches only if every part fits: direction, protocol, port, and source. Port 22 from the wrong address does not match an “allow port 22 from staff” rule.

Common Mistake 3 · Putting broad rules first

A broad allow (“port 443 from ALL”) above a specific deny cancels the deny. Specific rules usually go first.

Explain a firewall decision like this

“The packet is inbound TCP to port 22 from 203.0.113.8. It does not match Rule 1 (wrong source range), Rule 2 (wrong port), or Rule 3 (source not in 10.10.1.0/24). It matches Rule 4, which denies all inbound traffic, so the firewall denies it.”

Walk the rules in order, say why each earlier rule does not match, and name the first rule that does.