What is a Firewall? A Complete Guide to How Network Security Actually Works
If there's one piece of security technology almost everyone has heard of but very few people can actually explain, it's the firewall. It's been sitting quietly in the background of network security for decades — mentioned in every antivirus popup, every router settings page, every "is my computer safe" conversation — and yet most people couldn't tell you what it's actually doing.
Let's actually fix that. We'll go through what a firewall is, how it decides what traffic to let through, the different types you'll come across, and why this decades-old concept is still absolutely central to network security today.
What is a Firewall?
A firewall is a network security device or piece of software that monitors and controls incoming and outgoing network traffic based on a defined set of security rules. Think of it as a checkpoint sitting between your network (or device) and the outside world — every piece of traffic that wants to pass through gets checked against the rules first, and only traffic that's explicitly allowed actually gets through.
The name itself comes from the physical concept of a firewall in construction — a barrier designed to stop fire from spreading between sections of a building. A network firewall does something conceptually similar: it stops unwanted or malicious traffic from spreading between an untrusted network (usually the internet) and a trusted one (your home or office network).
How Does a Firewall Actually Decide What to Block?
Firewalls make decisions based on rules, and those rules typically look at a few key pieces of information about each piece of traffic:
- Source and destination IP address — where the traffic is coming from and where it's headed
- Port numbers — which service the traffic is trying to reach (this connects directly to what we covered in our Nmap article, where ports represent open doors into a system)
- Protocol — whether the traffic is using TCP, UDP, or another protocol (we've broken both of these down in detail if you need a refresher)
- Connection state — whether this is a new connection attempt or part of an already-established, legitimate session
Based on these factors, the firewall either allows the traffic through, blocks it outright, or in some configurations, logs it for review. A well-configured firewall essentially operates on the principle of "deny by default, allow by exception" — meaning nothing gets through unless there's a specific rule permitting it.
Types of Firewalls
1. Packet-Filtering Firewalls
The most basic type, examining each packet individually against a set of rules — checking things like source/destination IP and port, without any awareness of whether that packet belongs to a larger, legitimate conversation. Fast and simple, but limited in what it can actually detect.
2. Stateful Inspection Firewalls
A significant step up — these track the state of active connections, so the firewall understands whether a packet is part of an established, legitimate session or an unexpected, potentially malicious one. Most modern firewalls, including pfSense, operate this way.
3. Proxy Firewalls (Application-Level Gateways)
These act as an intermediary between the internal network and the outside world, inspecting traffic at the application layer rather than just the network layer. This allows for deeper inspection, though often at the cost of some speed.
4. Next-Generation Firewalls (NGFW)
Modern firewalls that combine traditional filtering with additional capabilities like intrusion prevention, deep packet inspection, and application awareness — essentially bundling multiple security layers into one device.
5. Software Firewalls
Firewalls that run directly on a device, like Windows Firewall or macOS's built-in firewall, protecting that specific machine rather than an entire network.
6. Hardware Firewalls
Dedicated physical devices (or repurposed hardware running firewall software, like a pfSense box) sitting between a network and the internet, protecting every device on that network at once rather than one machine at a time.
Firewall vs Antivirus: Not the Same Thing
| Feature | Firewall | Antivirus |
|---|---|---|
| Primary Job | Controls network traffic in and out | Detects and removes malicious software |
| Where It Operates | At the network boundary or device's network stack | On files and running processes on a device |
| What It Stops | Unauthorized network connections and traffic | Viruses, trojans, and other malware |
These two work best together, not as substitutes for one another — a firewall can't detect a malicious file already sitting on your device, and antivirus software generally isn't built to filter network traffic at scale.
What a Firewall Can't Do
It's worth being realistic about limitations here, because firewalls are often treated as a complete security solution when they're really just one layer of many:
- A firewall generally can't detect malware already present on a device
- It can't stop attacks that come through allowed traffic, like a phishing email that gets through because email traffic is permitted by design
- It can't protect against insider threats operating within the allowed network
- Basic firewalls often can't inspect encrypted traffic in depth without additional configuration
This is exactly why firewalls are usually just one piece of a larger security setup, working alongside things like antivirus software, intrusion detection systems, and good password practices rather than standing in as the only line of defense.
A Real-World Example: pfSense
If you want to see everything discussed here in action, our pfSense article covers a real, widely used open-source firewall platform. It's a genuinely good way to see stateful inspection, rule-based traffic control, and even VPN and intrusion detection features working together in a single, practical system — useful whether you're studying for a networking exam or setting one up for your own home lab.
Final Thoughts
A firewall isn't flashy, and it doesn't get talked about with the same excitement as newer buzzwords in security, but it remains one of the most foundational pieces of network defense that exists. Every packet that crosses the boundary between a trusted and untrusted network is, in some form, being judged by a firewall's rules — and understanding how that judgment actually happens is genuinely essential groundwork for anyone getting serious about networking or cybersecurity.
If you've already read our TCP, UDP, and Nmap articles, this one ties directly back into all of them — a firewall's decisions are built entirely around the same ports, protocols, and connection states those articles cover in detail.
If this helped, check out our other cybersecurity breakdowns — more are coming soon.

Comments
Post a Comment