A firewall sits on the boundary between networks, such as the internet and an internal network, or segments of a data centre, and decides for each packet whether to pass or drop it. The decision is made by rules: which addresses and ports are allowed, in which direction a connection may be opened, and what to do with packets that no rule describes.
Stateful inspection
The main difference between a modern firewall and a simple filter is the connection table. When a computer on the internal network opens a connection, the firewall remembers it and lets the reply packets through automatically, without separate rules for each case. A packet from outside that pretends to be a reply to a nonexistent connection does not match the table and is dropped. NIST calls this approach stateful inspection, as opposed to simple packet filtering (stateless): a stateless filter compares each packet with the rules on its own, so allowing outgoing connections while denying incoming ones are two mutually exclusive tasks for it.
| Criterion | Stateless filter | Stateful firewall |
|---|---|---|
| What it sees | each packet on its own | the packet and the connection it belongs to |
| Reply packets | must be allowed by separate rules | passed on the strength of a connection table entry |
| Speed | simple, predictable processing | memory for the table, an entry lookup for every packet |
| Where it is found | ACLs on switches and routers | network edge, routers, server operating systems |
Where you find them
- personal: built into the OS, such as Windows Firewall, or
firewalldandnftableson Linux; - perimeter: on a router or a standalone device between the network and the internet; on Linux routers the role is played by
nftablesandiptables, and in RouterOS by the/ip firewall filterrules; - next-generation firewall (NGFW): adds application recognition, a built-in intrusion prevention system (IPS) and TLS inspection;
- WAF: a firewall for web applications that parses HTTP requests and catches SQL injection and other application-layer attacks;
- cloud: security groups and network ACLs, configured with rules in the cloud console.
Example rules
/ip firewall filteradd chain=forward action=accept connection-state=established,relatedadd chain=forward action=drop connection-state=invalidadd chain=forward action=drop connection-state=new in-interface=ether1 dst-port=22 protocol=tcpThe default rule is “deny everything that is not explicitly allowed” (NIST calls this deny by default). Rule order matters: the first matching rule decides the packet’s fate.
Sources
the term is written from these pagesVerified 9 Nov