Firewall
A network security device or software layer that filters incoming and outgoing traffic based on rules, blocking or allowing packets by source, destination, port, protocol, or content.
Last updated:
What is a firewall?
A firewall is a device or software layer that enforces a security policy on network traffic passing through it. It inspects each packet (or connection) against a list of rules and either permits, denies, or rejects the traffic. Firewalls are typically placed at network boundaries — between a home/office network and the internet, between a server and the public internet, or between isolated network segments inside an organization.
Every major operating system includes a built-in firewall (iptables/nftables on Linux, Windows Defender Firewall, pf on macOS and BSD), and every router sold to consumers has one too.
Types of firewall
Firewalls have evolved significantly over four generations:
- Packet-filter firewalls — the original design, making decisions on a per-packet basis using 5-tuple rules (source IP, source port, destination IP, destination port, protocol). Stateless and fast.
- Stateful firewalls — track connection state so reply traffic is automatically allowed without explicit rules. Modern baseline.
- Application-layer (proxy) firewalls — understand the contents of HTTP, SMTP, and other protocols, not just the headers. Can block SQL injection, malware downloads, etc.
- Next-generation firewalls (NGFW) — combine stateful filtering, deep packet inspection, IDS/IPS, TLS inspection, and threat intelligence feeds.
Common rule structures
A basic firewall rule looks like:
ACTION PROTOCOL SOURCE DESTINATION PORT
ALLOW TCP 203.0.113.0/24 0.0.0.0/0 443
DENY ALL 0.0.0.0/0 0.0.0.0/0 ANY
The principle of least privilege is the rule of thumb: start with a default-deny policy and add ALLOW rules only for the specific traffic you need. Most breaches involve services that were unintentionally exposed to the internet by overly broad firewall rules.
Testing firewall rules
Our port checker performs an external TCP probe to verify whether a rule is actually allowing or blocking traffic as intended, and our CIDR to IP range tool converts CIDR blocks into explicit start/end addresses for firewalls that don't natively support CIDR syntax.