Loading content...
The packet filter firewall represents the genesis of network firewall technology—the original mechanism that transformed routers from simple traffic forwarders into security enforcement points. Despite being the oldest firewall technology, packet filtering remains the foundational layer upon which all modern firewall technologies are built, and pure packet filters continue to provide high-performance filtering at network choke points where more sophisticated inspection would create unacceptable latency.
To understand packet filtering, imagine a border checkpoint where guards examine only the exterior of vehicles—checking license plates (IP addresses), noting the driver's stated destination (destination port), and verifying the vehicle type (protocol)—without ever opening the cargo. This surface-level inspection enables rapid processing of thousands of vehicles per hour, but it cannot detect contraband hidden within.
Packet filters operate on the same principle: they examine the metadata of network traffic—the headers that describe where packets came from, where they're going, and what protocol they carry—while remaining completely blind to the content those packets contain. This design produces firewalls that are extraordinarily fast but limited in their ability to detect sophisticated threats.
By the end of this page, you will understand packet filter firewalls at a level that enables you to configure them effectively, recognize their limitations, and explain precisely how they process traffic. You will learn the specific header fields available for filtering, understand rule construction and evaluation, and appreciate why this 'simple' technology remains relevant in modern networks.
Packet filter firewalls operate at OSI Layers 3 (Network) and 4 (Transport). This positioning gives them access to:
Layer 3 (Network Layer) Fields:
Layer 4 (Transport Layer) Fields:
What Packet Filters Cannot See:
Pure packet filters are stateless—each packet is evaluated independently without knowledge of previous packets or ongoing connections. The firewall has no memory of traffic that has already passed.
This stateless nature has profound implications:
| Aspect | Stateless Behavior |
|---|---|
| Connection tracking | None—firewall doesn't know if packet belongs to established connection |
| Return traffic | Must be explicitly permitted by separate rules |
| Resource usage | Minimal—no state tables to maintain |
| Performance | Maximum—no state lookups required |
| Security | Limited—cannot validate connection legitimacy |
Packet filters are implemented in several locations throughout network infrastructure:
1. Router Access Control Lists (ACLs) Most routers include packet filtering capabilities in the form of ACLs. Every packet traversing the router can be evaluated against ACL rules.
2. Operating System Network Stacks All major operating systems include packet filtering:
3. Dedicated Firewall Appliances While modern appliances offer stateful and deep packet inspection, they often include high-speed packet filtering as a first-pass optimization layer.
4. Network Interface Cards (NICs) Some high-performance NICs include hardware packet filtering capabilities, offloading simple filter rules from the CPU.
Understanding exactly which fields are available for filtering is essential for constructing effective packet filter rules. Let's examine each criterion in depth.
IP addresses can be filtered as individual hosts or network ranges using CIDR notation:
Individual Host:
192.168.1.100 # Single IPv4 host
2001:db8::1 # Single IPv6 host
Network Ranges (CIDR):
192.168.0.0/16 # 65,536 addresses (192.168.0.0 - 192.168.255.255)
10.0.0.0/8 # 16,777,216 addresses (entire 10.x.x.x space)
2001:db8::/32 # IPv6 /32 allocation
Special Addresses:
0.0.0.0/0 # Any IPv4 address (wildcard)
::/0 # Any IPv6 address (wildcard)
Source vs. Destination:
Filtering by IP address is fundamental but has significant limitations. IP addresses can be spoofed, are often dynamically assigned, and don't inherently indicate user identity or intent.
| Protocol | IP Protocol Number | Description | Common Filtering Use |
|---|---|---|---|
| ICMP | 1 | Internet Control Message Protocol | Permit ping, block directed broadcasts |
| IGMP | 2 | Internet Group Management Protocol | Multicast control (often blocked at perimeter) |
| TCP | 6 | Transmission Control Protocol | Most application traffic filtering |
| UDP | 17 | User Datagram Protocol | DNS, VoIP, streaming, gaming |
| GRE | 47 | Generic Routing Encapsulation | VPN tunneling protocols |
| ESP | 50 | Encapsulating Security Payload | IPsec encrypted traffic |
| AH | 51 | Authentication Header | IPsec authenticated traffic |
| ICMP6 | 58 | ICMPv6 | IPv6 control messages |
| SCTP | 132 | Stream Control Transmission Protocol | Telecom signaling |
Port numbers identify specific services or applications. They range from 0 to 65,535 and are categorized as:
Well-Known Ports (0-1023): Reserved for privileged system services. On Unix-like systems, binding to these ports typically requires root privileges.
| Port | Protocol | Service | Security Consideration |
|---|---|---|---|
| 20, 21 | TCP | FTP | Insecure, prefer SFTP |
| 22 | TCP | SSH | Critical—limit source IPs |
| 23 | TCP | Telnet | Insecure—block at perimeter |
| 25 | TCP | SMTP | Email relaying—restrict carefully |
| 53 | TCP/UDP | DNS | DNS amplification attacks |
| 80 | TCP | HTTP | Web traffic—ubiquitous |
| 110 | TCP | POP3 | Email retrieval—prefer secure variants |
| 143 | TCP | IMAP | Email—prefer IMAPS (993) |
| 443 | TCP | HTTPS | Encrypted web, critical services |
| 445 | TCP | SMB | File sharing—block from internet |
Registered Ports (1024-49151): Assigned to specific applications by IANA but not privileged.
Dynamic/Private Ports (49152-65535): Used for ephemeral client connections and internal applications.
TCP flags control connection establishment, data transfer, and termination. Understanding flags enables sophisticated filtering:
SYN (Synchronize):
ACK (Acknowledge):
FIN (Finish):
RST (Reset):
PSH (Push):
URG (Urgent):
In stateless packet filters, the 'established' keyword (or checking for ACK flag without SYN) is used to permit return traffic without allowing new inbound connections. This works because legitimate response packets will always have the ACK flag set. However, this trick can be defeated by attackers who set the ACK flag on probe packets—a limitation that stateful firewalls address.
Understanding rule syntax requires familiarity with how different systems express packet filter rules. Let's examine the most common formats and their practical application.
Every packet filter rule contains these elements:
1234567891011121314151617181920212223242526272829303132
! Extended ACL syntax:! access-list <number> <action> <protocol> <source> <source-wildcard> ! [operator port] <destination> <dest-wildcard> [operator port] ! Example 1: Permit HTTP traffic to web serveraccess-list 101 permit tcp any host 192.168.1.10 eq 80 ! Example 2: Permit HTTPS traffic to web serveraccess-list 101 permit tcp any host 192.168.1.10 eq 443 ! Example 3: Permit SSH from management network onlyaccess-list 101 permit tcp 10.0.0.0 0.0.0.255 any eq 22 ! Example 4: Permit established TCP connections (ACK flag set)access-list 101 permit tcp any any established ! Example 5: Permit DNS queriesaccess-list 101 permit udp any any eq 53 ! Example 6: Permit ICMP echo-reply (ping responses)access-list 101 permit icmp any any echo-reply ! Example 7: Block all SMB traffic from internetaccess-list 101 deny tcp any any eq 445access-list 101 deny udp any any eq 445 ! Implicit deny at end of ACL! access-list 101 deny ip any any (implicit) ! Apply ACL to interfaceinterface GigabitEthernet0/0 ip access-group 101 in12345678910111213141516171819202122232425262728293031323334353637
#!/bin/bash# iptables packet filter rule examples # Syntax: iptables -A <chain> -p <protocol> --dport <port> -j <action># Chains: INPUT (incoming), OUTPUT (outgoing), FORWARD (routed) # Set default policies to DROP (default deny)iptables -P INPUT DROPiptables -P FORWARD DROPiptables -P OUTPUT ACCEPT # Permit established and related connectionsiptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Permit loopback interface (localhost)iptables -A INPUT -i lo -j ACCEPT # Permit SSH from specific networkiptables -A INPUT -p tcp -s 10.0.0.0/24 --dport 22 -j ACCEPT # Permit HTTP and HTTPS to alliptables -A INPUT -p tcp --dport 80 -j ACCEPTiptables -A INPUT -p tcp --dport 443 -j ACCEPT # Permit ICMP ping requests (rate limited)iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT # Block SMB from any sourceiptables -A INPUT -p tcp --dport 445 -j DROPiptables -A INPUT -p udp --dport 445 -j DROP # Deny and log all other inbound trafficiptables -A INPUT -j LOG --log-prefix "IPTables-Dropped: "iptables -A INPUT -j DROP # Save rules (varies by distribution)# iptables-save > /etc/iptables/rules.v41234567891011121314151617181920212223242526272829303132333435363738
# pf.conf - BSD Packet Filter configuration # Define interfacesext_if = "em0" # External interfaceint_if = "em1" # Internal interface # Define network rangesinternal_net = "192.168.1.0/24"admin_net = "10.0.0.0/24" # Tables for dynamic contenttable <bruteforce> persist # Set default policiesset block-policy dropset skip on lo0 # Scrub packets (normalize/reassemble)match in all scrub (no-df max-mss 1440) # Block all by defaultblock all # Permit outbound traffic with statepass out on $ext_if proto { tcp, udp, icmp } from any to any keep state # Permit ICMP (ping) with rate limitingpass in on $ext_if proto icmp from any to any icmp-type echoreq keep state \ (max-src-conn-rate 3/10) # Permit SSH from admin network onlypass in on $ext_if proto tcp from $admin_net to any port 22 keep state # Permit HTTP/HTTPS to web serverpass in on $ext_if proto tcp from any to 192.168.1.10 port { 80, 443 } keep state # Block brute-force attackers (dynamic table)block in quick from <bruteforce>While the concepts are universal, syntax varies significantly between platforms. Cisco uses wildcard masks (inverse of subnet masks), iptables uses chains and match modules, and pf uses macro definitions and tables. Always consult platform documentation for exact syntax.
Understanding how packet filters process rules is critical for both correctness and performance. Misunderstanding rule order is one of the most common causes of firewall misconfigurations.
Packet filter rules are evaluated sequentially from top to bottom. When a packet matches a rule, the specified action is taken immediately, and no further rules are evaluated.
Consider this rule set:
Rule 1: DENY traffic from 10.0.0.100 to any
Rule 2: PERMIT traffic from 10.0.0.0/24 to any
Rule 3: DENY all traffic
Packet from 10.0.0.100:
Packet from 10.0.0.50:
Packet from 172.16.0.1:
In high-throughput environments, packet filter performance becomes critical. Every rule evaluated adds processing latency.
Optimization Strategies:
1. Place High-Volume Rules First Rules that match most traffic should be evaluated early. If 80% of your traffic is HTTP/HTTPS, placing those permit rules early reduces average evaluation depth.
2. Combine Rules Where Possible Instead of:
PERMIT any to 192.168.1.10 port 80
PERMIT any to 192.168.1.10 port 443
PERMIT any to 192.168.1.10 port 8080
Use port ranges or groups:
PERMIT any to 192.168.1.10 port 80,443,8080
3. Use Hardware Acceleration Many routers and firewalls can offload simple packet filter rules to hardware ASICs, achieving line-rate performance. Complex rules may fall back to software processing.
4. Remove Unused Rules Periodically audit rule hit counters. Rules with zero hits may indicate:
5. Use Object Groups Modern systems support grouping objects (IP addresses, ports) into named sets. This improves both manageability and performance:
object-group network WEB_SERVERS
host 192.168.1.10
host 192.168.1.11
host 192.168.1.12
object-group service WEB_PORTS
tcp eq 80
tcp eq 443
tcp eq 8080
permit tcp any object-group WEB_SERVERS object-group WEB_PORTS
Let's examine specific scenarios where packet filters are commonly deployed and the rule patterns that address each use case.
At the internet edge, fundamental anti-spoofing rules prevent attackers from sending packets with forged source addresses:
Block RFC 1918 Private Addresses Inbound:
DENY from 10.0.0.0/8 inbound
DENY from 172.16.0.0/12 inbound
DENY from 192.168.0.0/16 inbound
Block Your Own Addresses Inbound:
DENY from <your_public_ip_range> inbound on external interface
Block Bogon Addresses: Reserved, unallocated, or documentation-only address ranges shouldn't appear on the public internet.
Limit access to specific services based on source network:
SSH Access Restricted to Admin Network:
PERMIT tcp from 10.0.0.0/24 to any port 22
DENY tcp from any to any port 22
Database Access Restricted to Application Servers:
PERMIT tcp from 192.168.1.0/24 to 192.168.2.100 port 3306
PERMIT tcp from 192.168.1.0/24 to 192.168.2.100 port 5432
DENY tcp from any to 192.168.2.0/24 port 3306
DENY tcp from any to 192.168.2.0/24 port 5432
Block known-dangerous protocols at the perimeter:
Block Telnet, FTP, and Unencrypted Protocols:
DENY tcp from any to any port 21 ! FTP
DENY tcp from any to any port 23 ! Telnet
DENY tcp from any to any port 110 ! POP3 (unencrypted)
DENY tcp from any to any port 143 ! IMAP (unencrypted)
Block SMB and RPC (Wormable Protocols):
DENY tcp from any to any port 135 ! RPC
DENY tcp from any to any port 137-139 ! NetBIOS
DENY tcp from any to any port 445 ! SMB
The WannaCry ransomware outbreak of 2017 spread via SMB (port 445). Organizations that blocked SMB at their perimeters were protected. Many that didn't suffered catastrophic damage. Simple packet filtering of dangerous protocols at network boundaries remains one of the most effective defensive measures.
Some packet filter implementations support basic rate limiting:
ICMP Rate Limiting:
PERMIT icmp echo-request from any, limit 1 per second
DENY icmp echo-request from any
This permits ping but prevents ICMP-based denial-of-service attacks.
Log All Denied Traffic:
DENY and LOG all traffic not matched by previous rules
Log Access to Sensitive Systems:
PERMIT and LOG tcp from any to database-servers port 3306
Logging is essential for:
Understanding packet filter limitations is as important as knowing their capabilities. These limitations drove the development of more sophisticated firewall technologies.
1. No Connection Awareness Stateless packet filters don't understand connection state. This creates several problems:
2. No Content Inspection Packet filters cannot detect:
3. Port-Based Filtering Is Easily Evaded Attackers routinely tunnel through permitted ports:
4. IP Spoofing Vulnerability While egress filtering helps, inbound traffic may contain spoofed source addresses (particularly UDP traffic where no handshake validates the source).
IP fragmentation creates particular challenges for packet filters. When a packet exceeds the MTU (Maximum Transmission Unit) of a network link, it is divided into fragments.
The Problem:
Attack Scenario: An attacker could:
Mitigations:
Modern firewalls typically implement fragment tracking, but pure packet filters remain vulnerable.
At network perimeters, consider blocking all fragmented traffic while ensuring Path MTU Discovery (PMTUD) functions correctly for legitimate large packets. Most modern applications don't require fragmentation, and blocking it eliminates an entire class of evasion techniques.
IPv6 introduces several considerations that packet filter administrators must understand. Simply translating IPv4 rules to IPv6 syntax is insufficient.
ICMPv6: Unlike IPv4 where ICMP can often be blocked wholesale, ICMPv6 is essential for IPv6 operation:
| ICMPv6 Type | Purpose | Filter Recommendation |
|---|---|---|
| 1 | Destination Unreachable | MUST permit (path MTU discovery) |
| 2 | Packet Too Big | MUST permit (PMTU discovery) |
| 3 | Time Exceeded | SHOULD permit (diagnostics) |
| 128/129 | Echo Request/Reply | PERMIT (optional but useful) |
| 133-136 | Router/Neighbor Discovery | MUST permit on local links |
| 137 | Redirect | Block at perimeter |
Blocking all ICMPv6 will break IPv6 connectivity.
IPv6 uses extension headers for options that IPv4 placed in the IP header. These create filtering challenges:
Security Concerns:
IPv6 addresses are 128 bits (vs IPv4's 32 bits), using hexadecimal notation:
IPv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Shortened: 2001:db8:85a3::8a2e:370:7334
Common prefixes:
::/128 # Unspecified address
::1/128 # Loopback
fe80::/10 # Link-local
fc00::/7 # Unique local (similar to RFC 1918)
2000::/3 # Global unicast
Most networks run IPv4 and IPv6 simultaneously (dual-stack). This creates security complexity:
Many organizations have inadvertently enabled IPv6 through modern operating systems' default configurations. This 'shadow IPv6' network may bypass IPv4-only security controls. Ensure your packet filters explicitly address IPv6 traffic or disable IPv6 at the network level if not needed.
This page has provided comprehensive coverage of packet filter firewalls—the foundational technology upon which all modern firewall systems build. Let's consolidate the essential knowledge:
What's Next:
The limitations of packet filters—particularly the lack of connection state awareness—led directly to the development of stateful firewalls. In the next page, we'll explore how stateful inspection addresses these limitations by maintaining connection state tables and evaluating packets in the context of their associated connections.
You now possess expert-level understanding of packet filter firewalls. You understand their architecture, filtering criteria, rule syntax, processing order, common use cases, limitations, and IPv6 considerations. This knowledge forms the baseline against which you'll evaluate more sophisticated firewall technologies in subsequent pages.