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.
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.
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
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.
| Packet | Description | First matching rule | Result |
|---|---|---|---|
| A | visitor loading the website: inbound TCP port 443 from 203.0.113.8 | Rule 2 | ALLOW |
| B | website request from a blocked range: inbound TCP port 443 from 198.51.100.77 | Rule 1 | DENY |
| C | admin logging in from the staff subnet: inbound TCP port 22 from 10.10.1.15 | Rule 3 | ALLOW |
| D | login attempt from the internet: inbound TCP port 22 from 203.0.113.8 | Rule 4 | DENY |
| E | unrequested DNS traffic: inbound UDP port 53 from 203.0.113.8 | Rule 4 | DENY |
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
The admin login
Using the example ACL, what happens to an inbound TCP packet to port 22 from 10.10.1.15?
- 1Rule 1: denies TCP from
198.51.100.0/24. The source10.10.1.15is not in that range: no match. - 2Rule 2: allows TCP port 443. The port is 22: no match.
- 3Rule 3: allows TCP port 22 from
10.10.1.0/24. Direction, protocol, port, and source all match.
SSH from the internet
What happens to an inbound TCP packet to port 22 from 203.0.113.8?
- 1Rule 1: source not in
198.51.100.0/24: no match. - 2Rule 2: port 22, not 443: no match.
- 3Rule 3: port 22 matches, but the source is not in
10.10.1.0/24: no match. - 4Rule 4: denies all inbound traffic: match.
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?
- 1New Rule 1 would be “ALLOW inbound TCP port 443 from ALL.”
- 2The packet is inbound TCP port 443 from an address in ALL: it matches the new Rule 1.
- 3First match wins, so it is allowed; the deny rule for
198.51.100.0/24is never reached.
Direction matters
A rule reads DENY outbound TCP port 25 from ALL. What does it block, and why might an organization want it?
- 1Direction: outbound, traffic leaving the network.
- 2Criteria: TCP port 25, the port used for sending email between mail servers.
- 3Effect: computers inside cannot send email directly to outside mail servers.
- 4Why: 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.
6Common mistakes
The firewall stops at the first match. A later rule never overrides an earlier one for that packet.
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.
A broad allow (“port 443 from ALL”) above a specific deny cancels the deny. Specific rules usually go first.
“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.