Network Bytes · Episode 76 · CCNA 1.1
"Stateful firewalls: who gets in"
A firewall sits between your network and the internet and checks every packet against its rules. A stateful firewall also writes each conversation you start into a state table, so replies that match walk right in, while unsolicited packets with no match are dropped unless a rule allows them.
The firewall is a front desk
A firewall sits on the border between your network and the internet and checks every packet against a list of rules. A simple home or office policy reads like a building's front desk: "people from inside may go out to the web" and "nobody from outside comes in unless we expect them". In firewall terms that is allow outbound web traffic and deny everything else inbound. The last part is the implicit deny: anything no rule allows is dropped.
The state table
When your laptop opens a website, the request passes the desk and the firewall writes a row into its state table (also called a session or connection table): who is talking to whom. A typical row holds the inside address and port, the outside address and port, and the protocol, for example:
10.0.0.5 :50000 → 203.0.113.10 :443 (TCP)
Here 10.0.0.5 is your laptop (a private address), 50000 is the temporary source port your laptop picked, 203.0.113.10 is the web server and 443 is HTTPS. For TCP the firewall also tracks where the connection is in its life: opening, established or closing.
Replies in, strangers out
When the server's reply comes back, the firewall looks it up. It comes from 203.0.113.10 :443 and goes to 10.0.0.5 :50000, exactly the reverse of a row in the table, so it is part of a conversation you started and it walks right in. No inbound rule was needed.
A packet nobody asked for, say a stranger on the internet probing your laptop, has no matching row. Unless an inbound rule allows it, it is dropped. A firewall that remembers conversations like this is called stateful; the technique is often called stateful inspection. When the conversation ends or goes quiet for too long, its row is removed, so the door closes again.
Stateful vs stateless
A stateless filter keeps no list at all: it judges each packet on its own, by its addresses, ports and protocol. Router access control lists (standard and extended ACLs, EP57) work this way. They are fast and simple, but because they do not remember who started a conversation, they cannot tell a reply you asked for from a stranger's packet that looks the same. Most modern firewalls, including the one in your home router, are stateful. A next-generation firewall (NGFW) adds application awareness and an intrusion prevention system (IPS) on top of stateful filtering; that is a story for another episode.
Try it yourself
Open a website, then on Windows run netstat -n in a Command Prompt (on macOS or Linux, netstat -an or ss -tn). Each line is one of your conversations: your address and a high-numbered source port on the left, the server's address and port (often 443) on the right. That is the same information a stateful firewall writes into its state table. Find one line with :443 and note which source port your computer picked.
Good to know
- A stateful firewall tracks each connection (addresses, ports, protocol and, for TCP, the connection state) in a state or session table, and lets return traffic for a tracked connection back in without a separate inbound rule.
- Unsolicited inbound traffic is dropped unless a rule allows it (implicit deny).
- The "front desk" is a simplification: real firewalls also check TCP flags and timeouts.
- CCNA 1.1 lists "next-generation firewalls and IPS". A next-generation firewall adds application awareness and an IPS on top of stateful filtering, which this short leaves for later.
- Standard and extended ACLs on routers (EP57) are stateless.
10.0.0.5is a private address and203.0.113.10a documentation address (RFC 5737);50000is an example source port.
For CCNA learners
Exam topic 1.1.c Next-generation firewalls and IPS builds on this: know that a stateful firewall tracks sessions and allows matching return traffic automatically, while a stateless ACL judges every packet on its own, with no memory of the conversation.
Answer to the comment question
Two rules. A stateless filter does not remember the conversation, so it needs one rule to let your web requests out (for example, inside to any server on port 443) and a second rule to let the replies back in (from port 443 to your inside network). A stateful firewall only needs the first rule, because the state table lets the matching replies in on its own. The catch with the stateless version: that inbound rule lets in any packet that looks like a web reply, whether you asked for it or not.
Test your knowledge
Quick quiz: "Stateful firewalls: who gets in"
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- NIST, "SP 800-41 Rev. 1, Guidelines on Firewalls and Firewall Policy": stateful inspection tracks each connection in a state table with addresses, ports and connection state
- NIST, "ITL Bulletin October 2009, Protecting Information Systems with Firewalls": summary of SP 800-41 Rev. 1, stateful inspection and the state table
- Cisco Community, "How the firewall handles return traffic": return traffic matching the state table is admitted, unsolicited packets with no entry are dropped
- Cisco, "CCNA 200-301 v1.1 exam topics": 1.1.c next-generation firewalls and IPS
- IETF, "RFC 5737, IPv4 Address Blocks Reserved for Documentation": 203.0.113.0/24 used on screen
Video transcript
How does a firewall let your replies in, but keep strangers out?
A firewall sits between your network and the internet, and checks every packet against its rules. Think of a building's front desk.
When you visit a website, the desk writes it down: this laptop, that server, these ports. That list is the state table.
When the reply comes back, the desk checks its list. It matches a conversation you started, so it walks right in.
A packet nobody asked for has no match. Unless a rule allows it, it's dropped. Firewalls that remember conversations like this are called stateful.
A stateless firewall keeps no list at all. To browse the web through it, how many rules do you need? Comment your answer below!
That's your byte.
More from Network Bytes
- EP74"Packet capture basics (Wireshark)"
- EP75"Network Bytes recap: what's next"
- EP77"PoE: power over the cable"
- EP78"Virtual machines and hypervisors"