Course contentsShow
← Security
Lesson 431 of 3,05210. Network Security - Firewalls and SegmentationFree lesson

Stateful vs Stateless Rules

Compare stateful connection tracking with stateless packet filtering and their rule design implications.

Stateful vs Stateless Rules

You'll learn how stateful and stateless filtering approaches differ and why that matters when designing firewall rules.

The Core Difference

When a firewall inspects traffic, it can operate in two fundamentally different ways:

Stateless filtering examines each packet in isolation. The firewall looks at header information (source IP, destination IP, port, protocol) and decides whether to allow or block based solely on that single packet's characteristics. It has no memory of previous packets.

Stateful filtering tracks the context of network connections. The firewall remembers which connections have been established and automatically permits related return traffic, even if explicit rules don't mention it.

Why This Matters

Imagine you allow outbound HTTP requests (destination port 80). With stateless rules, you'd need two rules:

  • Allow outbound traffic to port 80
  • Allow inbound traffic from port 80 (for the response)

The second rule is dangerous—it allows any external server to initiate connections from port 80.

With stateful rules, you only need:

  • Allow outbound traffic to port 80

The firewall automatically permits the return traffic because it recognizes it as part of an established connection you initiated.

Rule Design Implications

Stateless firewalls require careful rule pairs for bidirectional communication, making rule sets larger and more error-prone. They're faster but less secure.

Stateful firewalls create simpler, more secure rule sets. You define intentions ("allow users to browse the web") rather than packet-level mechanics. The firewall handles tracking TCP handshakes, sequence numbers, and connection states.

Key Takeaway: Stateful firewalls track connection context and automatically handle return traffic, enabling simpler and more secure rules compared to stateless packet filters that examine each packet independently.