What is a firewall?
A firewall is a security system that sits between networks or devices and allows or blocks traffic by checking each packet against a list of rules.

Firewall
A firewall can be a dedicated box at the edge of a company network, a feature inside your home router, or software running on your laptop. In every case it does the same job: it sits between two networks, or in front of one device, and every packet that wants to cross has to pass through it. Think of a guard at an entrance with a printed list of who may come in and through which door.
It exists because, on a network, anything not on the list should be turned away. The guard only checks the list: addresses and ports, not intentions. That is both the strength of a firewall and its limit.
What a firewall actually checks
For each packet the firewall reads the headers: source IP address, destination IP address, protocol, and port. It compares them with its rules from top to bottom, and the first rule that matches decides. A simple rule set for a web server at 203.0.113.10 has three lines: anyone may reach 203.0.113.10 on TCP 443, only the admin network 198.51.100.0/24 may reach it on TCP 22, and everything else is denied. That last line is the default deny, the most important rule in the table: anything not explicitly allowed is blocked. Order matters. With the deny rule at the top, nothing would ever get through.
How a stateful firewall works
- A packet arrives. It carries a source, a destination, a protocol, and a port in its headers.
- The rules are checked. Top to bottom, first match wins: allow or block. No match means the packet is dropped.
- Connections are remembered. When your laptop opens a connection to port 443, the firewall records it in its state table.
- Replies get back in, strangers do not. The website’s answer matches that entry and is allowed. A packet from the internet that matches no connection is silently dropped.
That is what your home router already does every day. A plain packet filter looks at each packet on its own and has no memory. A stateful firewall keeps the state table, which is what most firewalls do today. A next-generation firewall (NGFW) also tries to identify the application behind the traffic, so it can tell that port 443 carries a video call or a file-sharing app. A network firewall protects a whole segment, a host firewall protects one computer, and the two work well together. Filtering outbound traffic matters as much as inbound: malware usually tries to call a server on the internet, and strict outbound rules make that harder and leave a trace in the logs.
A firewall is not protection from every attack
A firewall does not stop what it allows. A phishing link opened over permitted HTTPS passes straight through, because web traffic on port 443 is allowed, and a malicious website on that port looks the same as a harmless one. A firewall enforces rules. It does not judge intent. That is why it is one layer among several, alongside email filtering, endpoint protection such as EDR, and user awareness.
What to do
- Keep the firewall in your router and the one built into your computer switched on, and do not open ports you do not need.
- When you write rules, put the allow rules first and end with a deny-everything rule.
- Filter outgoing traffic too, so an infected machine cannot quietly call home.
- Do not rely on the firewall alone: a link you click over HTTPS is let through, so email filtering and endpoint protection still matter.
Watch it in 60 seconds
