A firewall is a system that inspects network traffic and allows or blocks it according to a set of rules. On a home network it mainly stops unsolicited connections from the internet reaching your devices, while letting the connections you start, such as loading a web page, flow normally.
Firewalls show up at just about every level: in your router, in your computer's operating system, in cloud platforms, and as dedicated appliances sitting in data centres. Some are simple filters that just check addresses and ports; others recognise specific applications and inspect content as it passes through. This guide walks through how each type works and which settings actually matter at home.
How firewall rules work
Every firewall compares traffic against a list of rules. A typical rule matches on some combination of:
- Direction: inbound (from the network to the device) or outbound.
- Protocol: TCP, UDP, ICMP and so on. See TCP vs UDP for why this distinction matters.
- Source and destination address: single IPs or ranges such as
198.51.100.0/24. - Source and destination port: for example TCP 443 for HTTPS.
- Interface or zone: the WAN side, the LAN side, a guest network.
Each rule carries an action: allow (accept), drop (silently discard) or reject (discard and tell the sender, with a TCP RST or ICMP message). Rules are usually evaluated top to bottom, and the first match wins — so order matters more than people expect. Anything that matches nothing falls through to the default policy. A secure configuration uses default deny for inbound traffic: block everything, then carve out specific exceptions.
Drop or reject?
Drop tells an outside scanner nothing and leaves it waiting on timeouts. Reject is friendlier on internal networks, since legitimate clients fail fast instead of hanging around. Plenty of setups drop on the internet-facing side and reject internally — best of both.
Types of firewalls
Stateless packet filters
The oldest type just examines each packet on its own, looking only at header fields — addresses, ports, protocol. Fast, but limited: to let replies to your own web requests back in, a stateless filter has to allow all inbound traffic from source port 443, and that's exactly the kind of thing an attacker can abuse by spoofing packets from that port. Router access control lists often work this way.
Stateful firewalls
A stateful firewall keeps track of connections in a state table instead. When your laptop opens a connection to 203.0.113.10 on port 443, the firewall logs it and automatically waves through the matching return traffic. An unsolicited packet from that server — or anyone else — has no matching entry, so it's blocked. Nearly every modern firewall is stateful, including the one baked into your home router and the ones built into Windows, macOS and Linux.
Application-layer firewalls and proxies
These understand specific protocols such as HTTP, DNS or SMTP. A proxy firewall terminates the client's connection and opens a fresh one to the server, which lets it inspect and enforce rules on the actual requests rather than just the packets. A web application firewall (WAF) is a specialised flavour of this that sits in front of websites to block attacks like SQL injection and cross-site scripting. WAFs and CDNs often add identifying response headers, which you can spot with our HTTP headers checker.
Next-generation firewalls (NGFW)
"Next-generation" is really just a label for firewalls that bolt extra features onto stateful filtering: identifying applications regardless of port, intrusion prevention, URL filtering, user-based rules tied to a directory, and sometimes decrypting TLS traffic for inspection. They're standard kit in business networks by now. It's worth remembering the term describes a feature set, not any kind of formal standard.
Host-based vs network-based
| Network firewall | Host firewall | |
|---|---|---|
| Where it runs | Router, appliance or cloud security group | On each computer or server |
| Protects | Every device behind it | Only that device |
| Sees traffic between local devices | No, not on the same subnet | Yes |
| Knows which program sent traffic | No | Yes, can filter per application |
| Examples | Home router firewall, cloud network ACLs | Windows Defender Firewall, macOS firewall, nftables, ufw |
The two complement each other more than compete. Take a laptop on public café Wi-Fi: there's no home router to protect it out there, so its host firewall is the only thing standing between it and the network.
Is NAT a firewall?
Not exactly, no. NAT translates private addresses to a public one, and because unsolicited inbound packets have nowhere to translate to, they get dropped as a side effect of that. It looks a lot like a stateful firewall from the outside, but it wasn't designed as a security control — UPnP and port forwarding punch holes right through it, and IPv6 usually skips NAT entirely. With IPv6, every device can carry a globally routable address, so the router's IPv6 firewall has to block unsolicited inbound traffic on purpose, not as a byproduct. Most home routers do this by default, but it's worth confirming rather than assuming.
Firewall examples on common systems
Linux with ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw enable
sudo ufw status verbose
Connected over SSH? Allow port 22 before enabling ufw, or you'll lock yourself out — a classic mistake.
Linux with nftables
ufw is just a front end; underneath, modern Linux runs on nftables. A minimal stateful inbound policy looks like this:
table inet filter {
chain input {
type filter hook input priority 0; policy drop;
ct state established,related accept
ct state invalid drop
iif "lo" accept
meta l4proto { icmp, ipv6-icmp } accept
tcp dport 22 accept
}
}
The ct state established,related line is what makes this stateful: replies to outbound connections get waved through, and everything else has to match an explicit rule. ICMPv6 gets allowed because IPv6 genuinely depends on it for neighbour discovery and path MTU discovery.
Windows
Get-NetFirewallProfile | Format-Table Name, Enabled, DefaultInboundAction
netsh advfirewall show allprofiles
Windows applies different rules depending on whether the network is classified as Domain, Private or Public. Mark untrusted networks as Public so file sharing and discovery stay locked down.
macOS
Open System Settings → Network → Firewall and turn it on. The macOS application firewall controls which apps are allowed to accept incoming connections; Options lets you block all incoming connections outright or enable stealth mode, which stops the Mac from answering probes such as ping.
Essential home firewall settings
- Keep the router firewall and SPI enabled. SPI (stateful packet inspection) is how many routers label their stateful firewall.
- Check the IPv6 firewall blocks unsolicited inbound connections.
- Disable remote (WAN) administration of the router unless you truly need it.
- Review port forwards and the DMZ setting. Remove anything you no longer use. Our guide to port forwarding covers safe practices.
- Consider turning off UPnP, which lets any local device open ports without asking.
- Leave host firewalls on on every computer, especially laptops.
- Put smart-home devices on a guest or IoT network where the router supports it, isolating them from your computers.
- Keep router firmware updated, since the firewall is only as good as the software running it.
Then go check from the outside, because that's where it counts. Our open port checker connects to your public IP from across the internet and shows whether a given TCP port is actually reachable. On a typical home connection with no forwarding rules set up, every port should come back closed or filtered.
Frequently asked questions
Do I need a firewall if I have a router?
Your router's firewall protects devices at home, but keep your computer's host firewall on as well. It protects you on other networks and blocks attacks from compromised devices on your own LAN, which the router never sees.
Should I block outbound traffic?
For home use, allowing outbound traffic by default is normal and practical. Businesses often restrict outbound traffic to limit malware communication and data exfiltration, but this requires maintaining allow-lists for every legitimate application.
Can a firewall slow down my internet?
Basic stateful filtering adds negligible delay. Features such as deep packet inspection, intrusion prevention or TLS decryption need substantial processing power, and on lower-end hardware they can limit throughput.
Why does my firewall block ping?
Many firewalls drop inbound ICMP echo requests to make devices less visible to scans. It does not affect normal browsing, but it means a ping test cannot tell you whether that host is up.
Komentar
Bagikan tips, ajukan pertanyaan, atau ceritakan pengalaman Anda memakai alat ini.