Concepts / Firewalls

Firewalls

Firewall

Also called packet filter, iptables, nftables, rule

Rules deciding, packet by packet, what may reach or cross a device.

Rules are read from the top; the first match decides
Rules are read from the top; the first match decides

A packet is checked against the rules in order, and the first rule that matches decides; the rest are not read. A packet to port 443 is accepted by rule 1. A packet to port 22 from 203.0.113.9 matches neither rule 1 nor rule 2, so the last rule drops it.

A firewall is a set of rules that decide, packet by packet, what may reach or cross a device. Each rule matches addresses, ports, interfaces or connection state, then accepts, drops or rejects; rules are read in order and the first match decides. Routing gets a packet somewhere; the firewall decides whether it may go. A network firewall only governs traffic that crosses it.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab