A packet filtering firewall gives Linux a simple way to sort traffic at the packet level. The kernel reads the header fields, checks them against its rules, and makes a decision that stays consistent under load. The logic isn’t fancy, but it shapes how the rest of the system handles new connections.
The process is predictable. Packets arrive, their basic fields get inspected, and the filtering layer decides whether they move forward or stop right there. No payload review. No protocol deep dive. Just enough structure for the system to keep its footing.
This article lays out that foundation so beginners can see how the filtering layer actually works inside Linux. Once the basic packet path is clear, the behavior of higher-level firewall tools becomes easier to understand, even when the setup remains simple.
Packet filtering is a basic check the system performs on every packet that reaches the kernel. A packet filtering firewall focuses on the packet header. That header is a small block of fields that the packet carries everywhere. It holds the source and destination addresses. It notes the protocol. It records the ports tied to the exchange, and that tiny set of values is enough for Linux to sort traffic quickly without reaching deeper layers. These fields give the system the minimum it needs to sort traffic. Nothing more.
The idea grew out of early network equipment that had to make quick decisions with limited resources. The pattern still holds. Internet background noise shows the same thing every day. Port scans, stray connection attempts, and misrouted packets all carry enough header data for the firewall to judge them without reading the payload. The kernel leans on that predictability.
The decision itself follows a straight line. The packet arrives. The header fields are compared to the rules in order. The first rule that fits determines what happens next. Some packets move forward. Some stop immediately. It is the simplest filtering model Linux uses, and it sets the base layer for everything that comes after, including more advanced stateful checks.
A packet filtering firewall only sees what is in the packet header. Everything else is invisible at this stage. Breaking the header down makes the filtering step easier to understand.
IP header fields the firewall can read:
These pieces tell the kernel where the traffic came from and what type of packet it is. Nothing in this layer describes the application itself. It is all structural data that the system can trust.
TCP header fields:
TCP gives the firewall a sense of how a connection is forming. A SYN flag signals a new attempt. A FIN signals a close. These are simple indicators, not full context, but they help the kernel understand the packet’s place in a flow.
UDP header fields:
UDP offers less information than TCP. The firewall still gets ports and protocols, which is usually enough for basic filtering, but there is no concept of connection steps.
Ports in plain terms:
Ports give a hint about the service behind the packet. The system reads them as numeric fields, and no more.
Flags in plain terms:
Flags help the kernel place a packet in time. They don’t reveal intent or payload, but they shape the early decision.
All Linux firewall tools interpret these same fields. Interfaces differ, but the packet does not. Even early questions about choosing a Linux firewall eventually circle back to this structure because the filtering decision begins and ends with what the header exposes.
Linux follows a steady evaluation path inside the kernel. Packets move through a small set of checkpoints, and each checkpoint gives the system a chance to make a filtering decision before the packet reaches anything higher in the stack.
Every packet hits Netfilter as soon as the kernel receives it. Netfilter assigns the packet to a chain based on direction, which keeps local traffic, outbound traffic, and transit traffic from mixing together in the filtering path.
Linux relies on three core chains for packet evaluation. INPUT checks packets headed to the local machine. OUTPUT handles packets generated by the host. FORWARD governs packets passing through the system. These chains form the backbone of Linux filtering behavior.
Rules sit inside tables, each built for a specific task. The filter table drives allow or drop decisions. NAT and other tables exist, but beginners mainly need to know that packets only touch the tables relevant to their path. The structure keeps evaluation predictable, a pattern reflected across major Linux distributions, including the Red Hat packet filtering documentation, which outlines the same table-driven model.
Netfilter processes rules in order. The kernel reads from the top of the chain, stops at the first rule that matches, and applies that result. The rest of the chain never runs. This simple flow explains why two similar rules can yield different outcomes.
A broad rule placed early can catch traffic before a more specific rule even appears in the evaluation path. The kernel is only following its first-match logic, yet the effect can be surprising. This is where topics like firewall rule ordering basics become useful for understanding real behavior.
All of these decision points rely on the same header fields described earlier. The chains and tables simply give Linux a structure for reading them. Once the packet’s path is clear, the rest of the filtering model becomes easier to map, even when different firewall tools present it in their own style.
Stateful filtering expanded what Linux could do with packet decisions. Instead of treating every packet as a separate event, the system tracks how a connection forms and uses that memory to guide later decisions. It is a small shift in logic that changes the whole filtering model.
Stateful packet filtering keeps a record of traffic that has already been approved. A new packet is marked as the start of a connection. Follow-up packets are marked as established. Related packets fall into a secondary category that still fits the flow. The firewall can make better judgments because it knows where the packet sits in the conversation.

Connection tracking holds a lightweight entry for each active connection. It does not store payloads or application data. It just records enough detail for the kernel to match replies to earlier packets. This keeps the evaluation orderly. Tools aimed at beginners rely on this for predictable behavior, and topics like UFW basics highlight how the heavy lifting happens behind the scenes.
Without statefulness, the firewall would need broad rules to avoid blocking normal traffic. With it, the system sees which packets belong to a valid exchange and which do not. Established traffic moves with minimal checks. New traffic gets a closer look. It is one of the core steps that moved Linux away from older, strictly stateless models.
nftables reorganized how Linux handles filtering decisions. The firewall still checks packet headers the same way, but the path is cleaner, and the evaluation work sits closer to the packet flow. This keeps the packet filtering model consistent across tools.
Key parts of the nftables model:
These shifts don’t change the underlying ideas. Linux still reads the header, checks the state, and makes a decision. For someone working through the firewall troubleshooting steps, it helps to know that nftables reorganizes the filtering path without changing the core ideas.
Packet filtering matters because it gives the kernel a stable first decision on every packet, and that early verdict shapes how the rest of the firewall stack behaves. It also forms a big part of the groundwork people learn when they first look into Linux firewall basics, since most later behavior traces back to this early check.
Packet filtering ends up as the quiet anchor that keeps Linux firewall behavior consistent, even as rule sets and tools evolve around it.
A few misunderstandings show up early when people start looking at how Linux evaluates packets. Much of it comes from expecting a packet filtering firewall to see more than it actually can or from mixing up how different layers of the system behave.
Clearing these points early keeps the filtering model steady before moving into more advanced pieces of the firewall stack.
A few questions come up often when people start learning how packet filtering works in Linux.
No. It only reviews the header fields. The payload stays untouched in this stage of the process.
It’s one part of a firewall. Packet filtering provides the first decision point, but higher layers build on that foundation.
Yes. Even with newer designs, the header check remains the starting point for how Linux decides what to do with a packet.
Packet filtering sits at the base of Linux firewalling, and most of the system’s behavior traces back to this early inspection step. Once the packet’s path makes sense, the rest of the firewall stack settles into a clearer shape.
Rule ordering starts to feel more predictable because you understand why the kernel reaches a decision when it does. Stateful checks, which build on the same packet flow, become easier to read once you see how new and established traffic forms at the header level. Even egress control and basic troubleshooting rely on this groundwork, since every later step depends on how the packet was first classified.
Nothing in the next layer is more complicated. Each concept is just an extension of the logic introduced here, and the model holds up as the ruleset grows or the network gets louder. Packet filtering ends up being the foundation that keeps everything else steady. Once this layer makes sense, the rest of the firewall stack stops feeling unpredictable.