1-min guide

Firewalls and rule order

A firewall stands at the entrance to a company or home network and sorts traffic into “allow” or “block,” like a gatekeeper.

Reading time: about 1 min

More in the 5-min version →

In the game, this was a building managerPlay “The Building Manager”

In the gameIn real IT
VisitorIncoming traffic (packet)
AddressSource IP address
Town and blockFirst half of the IP address (network part)
NoticeRule table
Come in / SorryAllow / Deny
Everyone else: SorryDefault deny
Incoming trafficsource, port1. anywhere → 443 (HTTPS) allow2. anywhere → 80 (HTTP) allow3. outside → 22 (SSH) deny4. everything else denytop down
The first matching row decides; rows below it are not checked. The last row means “block everything else.”

What does it look at?

A firewall looks at a connection’s source and destination IP addresses, its destination port number (which service it’s for: 443 is HTTPS, 22 is SSH, and so on) and its protocol, and checks them against the rule table. This is called packet filtering.

Rules are read from the top; the first match decides

The rule table is checked one row at a time from the top, and the “allow” or “deny” of the first matching row decides. Rows below are not checked. That’s why order matters. For example, if you put “allow SSH from inside the company” below “deny all SSH,” SSH from inside gets stopped by the upper row too.

The last rule: “block everything else”

At the very bottom of the rule table goes a row that says “block any traffic that matched nothing above.” Allowing only what you need and blocking everything else is called default deny. It keeps intruders out of entrances you never opened.

Summary
  • Decide “allow or block” by source/destination IP address and port number
  • Rules are checked from the top, and the first matching row decides
  • The last row is “deny everything else”
Go further: 5-min deep diveFirewalls in depth: stateful inspection, DMZ and WAFIf you allow outgoing traffic, what about the replies? Where do public servers go? And the attacks a firewall can’t stop.Read the 5-min version →