When most people hear "firewall," they picture a single thing — the box between your network and the internet that blocks bad traffic. In reality, "firewall" describes an entire family of technologies with fundamentally different architectures, operating at different layers of the network stack, solving different security problems.
A packet filtering firewall and a Web Application Firewall are both called firewalls, but they operate as differently as a bouncer checking IDs at the door versus an expert reading body language inside the room.
This matters practically because choosing the wrong firewall for a specific security requirement leaves gaps that attackers exploit. A stateful firewall protecting a web application cannot inspect the HTTP payload for SQL injection.
A WAF protecting a database API has no ability to block port scans targeting other services. Organisations that understand the distinctions deploy the right tool for each layer of their security architecture — and do not rely on a single firewall type to solve all problems.
This guide covers every major firewall type in depth — packet filtering, stateful inspection, Next-Generation Firewalls, Web Application Firewalls, and cloud firewalls — with real configuration examples, the specific attacks each type can and cannot stop, vendor comparisons, and a corporate deployment framework that shows where each type belongs in a layered defence architecture.
- What is a firewall — and what it is not
- Type 1 — Packet filtering firewall
- Type 2 — Stateful inspection firewall
- Type 3 — Next-generation firewall (NGFW)
- Type 4 — Web Application Firewall (WAF)
- Type 5 — Cloud-native and virtual firewalls
- Side-by-side comparison — all firewall types
- Firewalls and the OSI model — which layer each operates at
- Top firewall vendors in 2026
- Corporate deployment framework — layering firewall types
- Frequently asked questions
A firewall is a network security control that monitors and filters traffic between network zones based on a defined rule set — permitting traffic that matches allowed patterns and blocking traffic that does not. It sits at the boundary between two or more network zones and acts as the enforcement point for the traffic policy between those zones.
Critically: a firewall is not an intrusion detection system (though NGFWs include IDS/IPS functionality). It is not an antivirus. It is not a VPN (though firewalls often terminate VPN connections). It is not a complete security solution on its own. A firewall enforces a network traffic policy — what can flow between zones, on what ports, using what protocols. Everything else in the security stack handles what happens at layers a firewall cannot inspect.
Every well-configured firewall operates on the principle of default deny: everything is blocked unless explicitly permitted. Rules are written to allow specific, required traffic flows. Any traffic not matching a permit rule is silently dropped or rejected. This is the inverse of how most networks are built without firewalls — where everything is permitted unless explicitly blocked.
Default deny is important because it means the security team must consciously decide what is allowed. Every open port, every permitted protocol, every allowed source-destination pair is a deliberate, documented decision. This mindset — explicit permit, implicit deny — is the foundation of all effective firewall policy.
A packet filtering firewall examines each network packet in isolation and compares it against an access control list (ACL). Each packet is checked against rules that specify: source IP address, destination IP address, source port, destination port, and protocol (TCP or UDP). If the packet matches a permit rule, it is forwarded. If it matches a deny rule or no rule at all, it is dropped. The decision is made independently for every single packet — there is no memory of previous packets and no concept of a "connection."
Packet filtering is implemented in router ACLs (Cisco IOS access-list commands), Linux iptables with simple rules, and basic firewall configurations. It is still widely used today — not as a primary firewall, but as a fast first-pass filter at network boundaries before traffic reaches more sophisticated controls.
| # | Protocol | Source IP | Dest IP | Dest Port | Action | Purpose |
|---|---|---|---|---|---|---|
| 1 | TCP | ANY | 10.0.0.5 | 443 | PERMIT | Allow HTTPS to web server |
| 2 | TCP | 10.10.99.0/24 | ANY | 22 | PERMIT | SSH from management subnet only |
| 3 | UDP | ANY | 10.0.0.2 | 53 | PERMIT | DNS to internal resolver |
| 4 | TCP | ANY | 10.0.0.0/8 | 23 | DENY | Block Telnet everywhere |
| 5 | ANY | ANY | ANY | ANY | DENY | Implicit deny all |
- Can stop: Port scans reaching closed ports, connections from blocked IP ranges, traffic on prohibited protocols, traffic to services not in the ACL, basic IP spoofing (with anti-spoofing rules)
- Cannot stop: Attacks through permitted ports (SQL injection on port 443 looks identical to legitimate HTTPS), IP spoofing where the source IP is in a permitted range, fragmented packet attacks (some packets bypass ACLs if fragmented correctly), return traffic attacks (no state tracking — cannot verify a packet is a legitimate TCP response)
Stateful inspection was introduced by Check Point in 1994 and solved the fundamental problem with packet filtering: a stateless firewall has no way to know whether an inbound packet is a legitimate response to an outbound request or an unsolicited attack packet. A stateful firewall maintains a connection state table — a record of every active TCP/UDP session crossing the firewall.
When a client initiates a TCP connection (SYN), the firewall records the session: source IP, source port, destination IP, destination port, and the current TCP state (SYN_SENT). When the server responds (SYN-ACK), the firewall verifies this packet matches an existing entry in the state table and updates it to ESTABLISHED. Return traffic matching an established session is automatically permitted without requiring a separate inbound rule. This eliminates the need for open inbound rules for return traffic — a major security improvement over packet filtering.
- SYN flood protection — SYN packets without corresponding ACKs are tracked. Flood conditions trigger SYN cookies or rate limiting. Packet filtering has no concept of "too many SYNs."
- No inbound rules for return traffic — stateful firewalls only need outbound permit rules. Return traffic is automatically permitted if it matches an established session. Packet filtering requires explicit inbound rules for return traffic, creating security gaps.
- TCP sequence number validation — verifies that TCP sequence numbers in packets are within the expected range for the session, blocking TCP session hijacking attempts.
- FTP, SIP helper inspection — protocols that open dynamic ports for data transfer (FTP's data channel, SIP's media streams) are handled by application layer helpers that track the negotiated secondary ports and permit only those — without opening broad port ranges.
- Still blind to payload — stateful inspection operates at Layer 3–4. It knows a valid TCP session on port 443 is established. It cannot see that the HTTPS payload contains a SQL injection string.
Linux iptables / nftables (with connection tracking module), Windows Firewall with Advanced Security, Cisco ASA (now Secure Firewall), older Check Point appliances, pfSense / OPNsense (open-source), and Fortinet FortiGate at basic configuration. Most modern deployments use these as the base layer of an NGFW rather than as standalone stateful firewalls.
The term "next-generation firewall" was defined by Gartner in 2009 to describe a new class of firewall that moved beyond stateful inspection to include deep packet inspection (DPI), application awareness, and integrated intrusion prevention. By 2026, NGFW is simply what most people mean when they say "firewall" — the stateful-only firewall is increasingly a legacy device.
Where stateful inspection tracks TCP sessions at Layer 4, DPI reads the actual content of each packet's payload. It reassembles TCP streams and inspects the application-layer data — the HTTP headers, the DNS query payload, the TLS certificate, the SMTP commands. This is what enables all the higher-level capabilities below.
Traditional firewalls identify applications by port. An NGFW identifies the actual application regardless of port — Skype on port 80, BitTorrent on port 443, Dropbox disguised as HTTPS. Palo Alto Networks' App-ID is the most advanced implementation: it identifies over 3,500 applications by analysing protocol behaviour, payload signatures, and traffic patterns. This prevents the common bypass technique of using non-standard ports or tunnelling traffic over common protocols.
Traditional firewalls operate on IP addresses. An NGFW integrates with Active Directory, LDAP, or RADIUS to map IP addresses to user accounts. Policies can be written as: "Allow Marketing group to access social media on port 443, deny Engineering group on the same policy." When a user's IP changes (DHCP reassignment), the policy follows the user identity, not the IP.
NGFWs include an intrusion detection and prevention system inline — inspecting traffic for known attack signatures (Snort/Suricata rule sets), protocol anomalies, and behavioural patterns. When an attack signature matches, the IPS can block the traffic in real time (prevention mode) or alert and log it (detection mode). This consolidates two previously separate appliances (firewall + IPS) into one.
Over 90% of internet traffic is now encrypted with TLS. A firewall that cannot decrypt TLS is largely blind to modern attacks — malware C2 communications, data exfiltration, and HTTPS-delivered exploits all look like generic encrypted traffic. NGFW TLS inspection works by acting as a trusted man-in-the-middle: the firewall terminates the TLS connection from the client, inspects the decrypted payload, then re-encrypts and forwards to the destination. This requires deploying the NGFW's CA certificate as a trusted CA on all managed endpoints.
- Can stop: Known malware signatures in traffic, C2 communications (known domains and IPs), application policy violations, URL category-based threats, TLS-encrypted attacks (with SSL inspection enabled), protocol anomaly-based attacks, many zero-day exploits via signature updates, DNS tunnelling, data exfiltration via known channels
- Cannot stop: Unknown zero-day attacks not yet in signature databases, attacks within encrypted traffic if TLS inspection is not deployed, SQL injection and XSS in web application payloads (these require a WAF that understands web application context, not just network traffic), insider threats using legitimate application sessions, advanced threats that evade signature detection
A Web Application Firewall operates exclusively at Layer 7 — it understands HTTP and HTTPS at a semantic level, not just as network traffic. While an NGFW sees "encrypted traffic on port 443," a WAF sees the actual HTTP request: the URI, query parameters, request headers, cookies, and POST body. This context is what enables it to detect web application attacks that are completely invisible to network-layer firewalls.
A WAF sits in front of web applications as a reverse proxy. All requests destined for the application are first received by the WAF, inspected, and either forwarded to the application (if clean) or blocked (if malicious). The application server only sees traffic that the WAF has cleared.
- SQL injection detection — pattern matching and heuristic analysis of SQL metacharacters, keywords (UNION SELECT, OR 1=1, DROP TABLE), and injection patterns in query parameters, POST bodies, headers, and cookies
- XSS detection — detection of JavaScript injection patterns, HTML event handlers, and script tags in user input before they reach the application
- CSRF protection — validation of anti-CSRF tokens, origin headers, and referrer validation for state-changing requests
- Rate limiting and DDoS mitigation — request rate limits per IP, per session, per endpoint; challenge-response (CAPTCHA) for suspicious traffic patterns
- Bot detection — distinguishing legitimate browsers and crawlers from automated attack tools through behavioural analysis, JavaScript challenges, and browser fingerprinting
- API security — schema validation (does this API request match the OpenAPI specification?), rate limiting per API key, detection of parameter pollution and mass assignment attacks
- OWASP Core Rule Set (CRS) — the open-source rule set used by ModSecurity and many commercial WAFs, covering all OWASP Top 10 vulnerability categories
The most common misunderstanding: organisations deploy an NGFW and believe their web applications are protected from SQLi and XSS. They are not. An NGFW sees HTTPS traffic on port 443 — with TLS inspection enabled, it can inspect the payload for known malware signatures and C2 patterns, but it has no semantic understanding of SQL syntax or HTML/JavaScript context. A WAF specifically understands web application attack patterns because it is designed to parse and understand HTTP at the application layer. Both are required for a complete web security posture — NGFW for network-layer control, WAF for application-layer protection.
As workloads migrate to the cloud, traditional hardware firewalls at the network perimeter become insufficient. Cloud environments require firewall controls that understand cloud-native concepts — virtual network interfaces, dynamic IP addressing, auto-scaling groups, serverless functions, and container networking — rather than static physical topology.
AWS Security Groups, Azure Network Security Groups (NSGs), and GCP Firewall Rules are cloud-native stateful packet filters. They operate at the virtual network interface level — each EC2 instance, Azure VM, or GCP compute instance has a Security Group that controls inbound and outbound traffic at Layer 3–4. They are automatically applied to all resources in the security group regardless of IP address changes.
Firewall-as-a-Service (FWaaS) delivers NGFW capabilities from the cloud without hardware. Traffic is routed through the vendor's cloud Points of Presence (PoPs) rather than backhauled to a central corporate firewall. This solves the performance problem of routing cloud and SaaS traffic through an on-premises NGFW and is the network enforcement mechanism in SASE (Secure Access Service Edge) architectures.
- Zscaler Internet Access (ZIA) — market-leading FWaaS. Traffic from users anywhere routes through Zscaler PoPs for NGFW inspection, URL filtering, DLP, and threat protection. No hardware required.
- Palo Alto Prisma Access — cloud-delivered Palo Alto NGFW capabilities with global PoP infrastructure. Brings Palo Alto's App-ID and security profiles to distributed workforces.
- Cloudflare Gateway — DNS and HTTP filtering at Layer 7, with network firewall for TCP/UDP traffic. Part of Cloudflare Zero Trust.
- AWS Network Firewall / Azure Firewall — managed NGFW services for filtering traffic within cloud VPCs without deploying firewall appliances. AWS Network Firewall uses Suricata-compatible rules.
| Type | OSI Layer | Stateful | App aware | IPS | TLS inspect | Stops SQLi/XSS | Best deployment |
|---|---|---|---|---|---|---|---|
| Packet Filtering | L3–L4 | No | No | No | No | No | Router ACLs, simple network edges |
| Stateful Inspection | L3–L4 + state | Yes | No | No | No | No | Network perimeter, inter-VLAN, VPN |
| NGFW | L3–L7 | Yes | Yes | Yes | Yes | Partial* | Primary perimeter, branch offices, DC edge |
| WAF | L7 only | Session-aware | Yes — HTTP | HTTP attacks | Terminates TLS | Yes — specialist | In front of every web app and API |
| Cloud Security Group | L3–L4 | Yes | No | No | No | No | Cloud instance-level access control |
| FWaaS / SASE | L3–L7 | Yes | Yes | Yes | Yes | Partial* | Distributed workforce, cloud-first orgs |
*Partial: NGFW and FWaaS with TLS inspection can detect some web attack signatures but lack the HTTP semantic understanding of a dedicated WAF. A WAF is required for comprehensive OWASP Top 10 protection.
| OSI Layer | What it carries | Firewall type that inspects here | What the inspection catches |
|---|---|---|---|
| Layer 3 — Network | IP packets — source/destination IP addresses, routing information | Packet filtering, stateful, NGFW, all types | Connections from blocked IP ranges, IP spoofing, geo-blocking |
| Layer 4 — Transport | TCP/UDP segments — ports, TCP flags, sequence numbers | Packet filtering, stateful, NGFW, all types | Port scanning, SYN floods, invalid TCP flags, port-based access control |
| Layer 5 — Session | Session establishment and management (NetBIOS, RPC, SQL*Net) | NGFW (via application proxies) | Protocol abuse, session anomalies in stateful protocols |
| Layer 6 — Presentation | TLS/SSL encryption, data encoding | NGFW with TLS inspection, WAF | Malicious TLS certificates, weak cipher suites, TLS tunnelling |
| Layer 7 — Application | HTTP, DNS, SMTP, FTP payload — the actual application data | NGFW (partially), WAF (specialist) | SQLi, XSS, malware downloads, C2 DNS queries, data exfiltration payloads, OWASP Top 10 |
| Vendor | Primary product | Strengths | Best for | Market position |
|---|---|---|---|---|
| Palo Alto Networks | PA-Series NGFW, Prisma Access (FWaaS) | Best-in-class App-ID, strongest security effectiveness ratings, rich telemetry for SIEM | Enterprise, high-security environments, zero trust adoption | Gartner Leader #1 for 10+ consecutive years |
| Fortinet | FortiGate NGFW, FortiSASE | Highest firewall throughput (custom ASIC), best price/performance ratio, broad product ecosystem | Mid-market to enterprise, performance-sensitive environments, SD-WAN | Gartner Leader, highest unit market share by volume |
| Check Point | Quantum NGFW, CloudGuard | Threat prevention efficacy, unified management (SmartConsole), strong compliance reporting | Enterprise, financial services, compliance-heavy environments | Gartner Leader, dominant in financial services |
| Cisco | Secure Firewall (formerly ASA+FTD), Umbrella (DNS) | Deep network ecosystem integration, SD-WAN, existing Cisco infrastructure leverage | Cisco-centric enterprises, government, education | Gartner Challenger — strong in existing Cisco shops |
| Cloudflare | Cloudflare WAF, Gateway, Magic Firewall | Global CDN + WAF at extreme scale, DDoS mitigation, zero trust integration, easy API | Web application protection, FWaaS for distributed teams, API security | WAF market leader by usage; zero trust growing |
| AWS / Azure / GCP | AWS WAF + Network Firewall, Azure Firewall, GCP Cloud Armor | Native cloud integration, zero infrastructure overhead, auto-scaling | Cloud-native workloads on respective platforms | Essential for respective cloud customers |
| Imperva | Cloud WAF, SecureSphere (on-prem) | Best-in-class WAF for complex web applications, strong API security, DDoS protection | Large web applications, API-heavy environments, e-commerce | WAF specialist leader |
| pfSense / OPNsense | Open-source stateful firewall + add-on packages | Free, flexible, excellent for learning and small environments, active community | Home labs, small businesses, security research, education | Leading open-source firewall platform |
No single firewall type solves all security requirements. A comprehensive corporate network defence uses multiple firewall types at different layers of the architecture — each solving the problems the others cannot. This is the layered defence-in-depth model.
⚡ Apply this to your network
- Audit which firewall types you currently have — do you have only an NGFW at the perimeter? Are your web applications behind a WAF? Are your network segments separated by firewall policies or just VLANs without enforcement? Map your current state before planning improvements.
- Deploy a WAF in front of every public web application — if you have public-facing web applications or APIs without a WAF, this is your highest-priority gap. Cloudflare's free tier WAF and AWS WAF provide entry-level protection. Enable the OWASP Core Rule Set in detection mode first, tune out false positives, then enable blocking mode.
- Enable TLS inspection on your NGFW — if you have an NGFW without TLS inspection enabled, you are blind to over 90% of your traffic. Deploy the NGFW CA certificate to managed endpoints via Group Policy and enable TLS inspection for non-sensitive categories. Exclude online banking and healthcare sites.
- Learn how firewalls fit network segmentation — firewalls are the enforcement mechanism between network segments. Without firewall policies between VLANs, segmentation is architectural theatre. Network segmentation guide →
- Understand how firewalls fit zero trust — NGFW and FWaaS are the network enforcement components of zero trust. ZTNA replaces VPN and complements perimeter firewalls by providing application-level access control for remote users. Zero trust architecture guide →
The main firewall types are: packet filtering (examines IP and port headers of individual packets, stateless), stateful inspection (tracks the state of TCP connections to verify packets are legitimate session traffic), next-generation firewall or NGFW (adds deep packet inspection, application identification, IPS, and TLS inspection to stateful inspection), Web Application Firewall or WAF (Layer 7 specialist that understands HTTP/HTTPS to detect SQLi, XSS, and other web attacks), and cloud firewalls (security groups, cloud WAF, and FWaaS for cloud-native and distributed environments). Enterprise networks typically deploy multiple types in layers.
A stateless (packet filtering) firewall examines each packet independently with no memory of previous packets. It cannot tell whether an inbound packet is a legitimate response to an outbound request or a new unsolicited connection — it only checks source IP, destination IP, and ports. A stateful firewall maintains a connection state table tracking the full TCP handshake and session state. Return traffic matching an existing established session is automatically permitted, and packets that do not match any known session are blocked — even if they have the correct source/destination IP and port. Stateful firewalls are significantly more secure and have been the standard since the mid-1990s.
A traditional firewall (including NGFW) operates at the network layer — it controls which IP addresses and ports can communicate. A Web Application Firewall (WAF) operates at the HTTP application layer — it understands the structure of web requests and can detect attack patterns in query parameters, POST bodies, cookies, and headers. A WAF can detect SQL injection and XSS because it parses HTTP semantics. A traditional firewall cannot — it sees valid HTTPS traffic on port 443 and has no way to see that the payload contains a malicious SQL statement. Both are required: the firewall controls network access, the WAF protects the application from malicious content.
A next-generation firewall (NGFW) combines traditional stateful packet inspection with deep packet inspection (reading packet payload content), application identification (identifying which application is generating traffic regardless of port), user identity awareness (mapping IP addresses to Active Directory users), integrated IDS/IPS (detecting and blocking known attack signatures), TLS/SSL inspection (decrypting encrypted traffic for inspection), and URL category filtering (blocking access to malicious or inappropriate websites). Defined by Gartner in 2009, NGFW is now the standard for enterprise perimeter and internal security, replacing basic stateful firewalls in most deployments.
TLS inspection involves the firewall decrypting, inspecting, and re-encrypting HTTPS traffic — a form of man-in-the-middle inspection that raises legitimate privacy and legal questions. For compliance: most enterprise security frameworks (PCI-DSS, ISO 27001, NIST) accept TLS inspection when it is documented, disclosed to users via acceptable use policies, and implemented with appropriate safeguards. Privacy considerations: exclude genuinely sensitive categories (personal online banking, healthcare portals, email accounts) from inspection. Legal considerations: employment contracts and acceptable use policies should inform employees that corporate traffic is subject to inspection. In many regulated jurisdictions, inspecting employee personal traffic on personal devices is prohibited even on corporate networks.
For a small business, a unified threat management (UTM) appliance or entry-level NGFW provides the best balance of security and simplicity. Fortinet FortiGate 40F–80F series, pfSense (open-source, free software), and Sophos XG are commonly recommended. For web application protection, Cloudflare's free tier WAF is excellent for small businesses with public websites — easy to configure and requires no hardware. The critical security controls for a small business, in priority order: (1) any decent stateful firewall between internet and internal network, (2) separate guest Wi-Fi VLAN for visitors, (3) WAF for any public web presence, (4) cloud DNS filtering (Cloudflare Gateway or Cisco Umbrella) to block malicious domains before they are reached.
Firewall-as-a-Service (FWaaS) delivers NGFW security capabilities from the cloud rather than from a hardware appliance. Instead of routing traffic through an on-premises firewall, traffic from users and devices is directed to the vendor's cloud PoPs (Points of Presence) where it is inspected and forwarded. FWaaS eliminates hardware procurement and maintenance, scales elastically with traffic volume, and provides consistent security policy regardless of where users are located — office, home, or travel. Traditional firewalls require backhauling traffic to a central location; FWaaS inspects traffic at the nearest PoP, typically reducing latency for cloud and SaaS applications. FWaaS is a core component of SASE (Secure Access Service Edge) architectures from vendors like Zscaler, Palo Alto Prisma, and Cloudflare.