Fact-checked by Grok 2 weeks ago

iptables

iptables is a userspace command-line utility in Linux that enables system administrators to configure and manage the tables of IP packet filter rules provided by the kernel's netfilter framework. Developed primarily by the netfilter core team since 1999, it supports IPv4 packet processing through the iptables tool and IPv6 via the companion ip6tables utility, requiring kernels from Linux 2.4.x onward with the ip_tables module enabled. At its core, iptables organizes rules into tables—such as the default filter table for basic packet filtering, the nat table for network address translation, the mangle table for packet modification, the raw table for exempting packets from connection tracking, and the security table for mandatory access control—each containing chains like INPUT, FORWARD, OUTPUT, PREROUTING, and POSTROUTING that define how packets are processed at various network stack points. Administrators can append, delete, insert, or list rules within these chains using commands that specify match criteria (e.g., source/destination IP, ports, protocols) and targets (e.g., ACCEPT to allow, DROP to discard, or REJECT to deny with feedback). Primarily used for firewall configuration, iptables facilitates packet filtering to control inbound and outbound traffic, to enable private networks to access the , and packet mangling for advanced or QoS adjustments, making it a foundational tool for securing Linux-based systems despite the rise of its successor, , within the same netfilter ecosystem.

Introduction

Purpose and Scope

iptables is a userspace utility program that enables system administrators to set up, maintain, and inspect the tables of filter rules within the . It provides the primary interface for interacting with the netfilter framework, a kernel-level system introduced in version 2.4 for handling network packets. The core functions of iptables revolve around managing IPv4 traffic through packet filtering, which determines whether to allow or block packets based on specified criteria; (NAT), which rewrites IP addresses and ports to enable private networks to access the ; and packet mangling, which modifies packet headers for tasks like adjusting time-to-live values or marking packets for special handling. These capabilities make iptables essential for implementing policies and enhancing in environments. While powerful, the scope of iptables is limited to IPv4 protocols, with a separate tool, ip6tables, handling IPv6 traffic in a similar manner. Launched alongside 2.4 in January 2001, iptables succeeded the ipchains system by expanding control over packet processing and integration with advanced kernel features. At its foundation, iptables operates via rules defined within organized structures called chains, where each rule evaluates packet attributes—such as source or destination , type, or port numbers—and applies a corresponding action, including acceptance, rejection, or alteration of the packet. This rule-based allows for granular control over behavior without requiring recompilation.

Relation to Netfilter

Netfilter serves as the foundational packet processing framework within the , providing a set of hooks that allow kernel modules to intercept and manipulate network packets at specific points in the networking stack. These hooks include PREROUTING, which occurs before routing decisions for incoming packets; INPUT, for packets destined to the local system after routing; FORWARD, for packets being routed to another host; OUTPUT, for locally generated packets before routing; and POSTROUTING, after routing for outgoing packets. This architecture enables efficient, modular packet handling directly in the kernel space. Iptables operates as the userspace to configure netfilter, translating administrative commands into kernel-level that populate netfilter's internal tables. When an iptables is applied, it loads the corresponding , such as ip_tables for IPv4, which registers the to match packets against specified criteria (classifiers) and execute actions (e.g., accept, drop, or alter) at the designated hooks. This process allows iptables to dynamically intercept packets during their traversal through the netfilter hooks, enabling features like filtering, , and logging without modifying the core code. The distinction between netfilter and iptables underscores a clear : netfilter manages the in-kernel packet flow and execution of registered callbacks, ensuring high-performance processing at wire speed, while iptables provides the mechanism from userspace, handling syntax, validation, and loading without direct packet involvement. This design promotes portability and ease of administration, as changes to s do not require kernel recompilation. Netfilter was introduced in the version 2.4 in 2001, concurrently with the initial release of iptables, replacing the earlier ipchains system and establishing a more extensible foundation. This evolution facilitated modular extensions through loadable kernel modules, allowing developers to add custom classifiers and actions (e.g., for connection tracking or QoS) without altering the base framework, thereby supporting a wide ecosystem of networking tools.

History and Development

Origins and Initial Release

iptables emerged as a pivotal advancement in firewall technology, developed by Paul "Rusty" in late 1999 as a core component of the netfilter project. This initiative began after , while performing sysadmin work, recognized the need for a more sophisticated packet filtering system to succeed the limitations of earlier tools like ipfwadm, introduced in 2.0 for basic IP firewalling, and ipchains, which arrived with kernel 2.2 but still operated within a single-chain model lacking true extensibility. The primary motivation was to create a modular framework supporting multiple tables for distinct functions such as filtering, , and mangling, thereby enabling greater flexibility and scalability in configurations that previous systems could not achieve. The netfilter project's core team formed in November 1999 when Russell met Marc Boucher in , marking a key collaboration that shaped iptables' architecture. Boucher, as the second core team member, contributed significantly by developing the mangle table and advocating for a generic packet selection mechanism, which integrated features like directly into iptables and eliminated the need for separate tools such as ipnatctl. Other early contributors, including James Morris and Harald Welte, joined soon after, forming the foundation of the netfilter core team that drove the project's rapid evolution. iptables was initially released and integrated into the with version 2.4.0 on January 4, 2001, representing a major upgrade in kernel networking capabilities. This integration allowed iptables to leverage netfilter's hook-based framework for efficient packet processing at various kernel points, a design that addressed the performance and modularity shortcomings of its predecessors, including stateful packet filtering via connection tracking. Following its debut, iptables saw rapid adoption in enterprise Linux distributions, such as those from , due to its enhanced control over network traffic and support for complex rulesets that better suited production environments. By providing a userspace to netfilter's kernel-level operations, it quickly became the for management, influencing security practices across servers and gateways in the early 2000s.

Key Versions and Transitions

iptables underwent several significant version updates that enhanced its functionality, particularly in supporting advanced packet matching and protocol extensions. Version 1.2.0, released in January 2001, provided initial userspace support for the , including fixes and compatibility improvements for early kernel versions. In 2007, version 1.4.0 marked a notable advancement in protocol support, with substantial improvements to handling via enhanced ip6tables integration, allowing for more robust filtering of IPv6 traffic. iptables maintained full kernel integration through versions up to 5.x, providing stable packet filtering via the netfilter hooks. However, with the introduction of in 3.13 (released in 2014), iptables was succeeded by the newer framework, which offered better extensibility and reduced kernel-userspace complexity. Despite this, iptables compatibility persisted through translation layers to ease migration. Major distributions initiated transitions to as the default backend during 2019–2021. 8 (2019) adopted by default while retaining iptables-legacy mode for , allowing users to switch via update-alternatives. Similarly, 20.04 (2020) shifted to an backend for iptables commands, with iptables-nft providing a hybrid interface and legacy support for existing rulesets. As of 2025, iptables remains maintained under the netfilter project, with the latest release being version 1.8.11 in November 2024, primarily focusing on bug fixes and minor enhancements rather than major feature additions. It is discouraged for new deployments in favor of , though legacy support ensures continued usability in established systems.

Architecture

Kernel-Level Components

Netfilter tables serve as core data structures in the networking stack, organizing and storing sets of rules that dictate packet processing behaviors. These tables are implemented within the netfilter framework and include five predefined types: the filter table for basic packet acceptance or denial, the nat table for , the mangle table for packet header modifications, the raw table for exempting packets from connection tracking, and the security table for enforcement. Each table maintains chains—linked lists of rules—that are evaluated sequentially during packet processing, with rules represented by structures such as struct ipt_entry in the kernel, which encapsulate matching criteria and associated actions. Packet processing occurs at specific netfilter hooks, which are predefined entry points in the where registered callback functions are invoked. There are five such hooks: NF_INET_PRE_ROUTING (upon packet ingress before decisions), NF_INET_LOCAL_IN (for packets destined to processes), NF_INET_FORWARD (for packets being through the system), NF_INET_LOCAL_OUT (for locally generated packets before ), and NF_INET_POST_ROUTING (after for outgoing packets). Chains from relevant tables are attached to these hooks based on the table's purpose; for instance, the table's chains are typically invoked at the input, forward, and output hooks. During traversal, the calls the registered functions in priority order, allowing modules to inspect, modify, or drop packets as they pass through the network stack. The functionality relies on dynamically loadable modules, such as those from the ip_tables family, which implement the table-specific logic for iptables. For example, the iptable_filter module (iptable_filter.ko) handles the filter table by registering its hooks and managing rule storage in kernel memory, while similar modules like iptable_nat.ko and iptable_mangle.ko support the nat and mangle tables, respectively. These modules are loaded on demand when userspace tools configure rules, interfacing with the kernel via the socket protocol to insert, update, or remove entries in the tables. The ip_tables backend is used by iptables, distinct from the newer nf_tables infrastructure primarily for , though both operate within the netfilter framework. In the packet lifecycle, incoming enters the at the prerouting , undergoes potential modifications or filtering, and proceeds through decisions, potentially hitting forward or local input hooks before reaching the destination handler or being forwarded out via postrouting. Outgoing packets follow a mirrored path starting from local output. evaluation happens at each applicable , with the linearly traversing the 's list until a match or the end (falling back to the 's default policy). This process ensures comprehensive inspection but introduces considerations, as linear traversal requires checking each sequentially, leading to potential throughput degradation from bloat in large configurations—where thousands of rules can increase and CPU utilization under high loads.

Userspace-Kernel Interaction

The interaction between userspace tools like the iptables binary and the kernel's Netfilter framework primarily relies on sockets for bidirectional communication, enabling the transmission of configuration commands and status queries. provides a socket-based interface that replaces traditional mechanisms, allowing userspace processes to send structured messages to the kernel for operations such as rule insertion, deletion, and modification in Netfilter tables. This protocol supports asynchronous notifications from the kernel to userspace, facilitating efficient updates without polling. The iptables binary leverages this interface through underlying libraries like libxtables or libiptc, invoking messages (in modern nft backend) or ioctl calls to manipulate structures. For instance, adding a rule involves constructing a message with rule specifications and sending it via a socket to the NETLINK_NETFILTER family, which the kernel processes to update the appropriate and . Similarly, deletions follow the same pattern but with removal directives. These operations target tables such as or , ensuring changes are applied atomically where possible. Error handling in this interaction is managed through return codes from kernel responses; for example, invalid rules may trigger EPERM (operation not permitted) if they violate policy or exceed limits, with the kernel providing feedback via attributes or ioctl error numbers for userspace interpretation. Operations require elevated privileges, typically access or the CAP_NET_ADMIN capability, which governs network administration tasks including firewall rule management; additionally, CAP_NET_RAW may be needed for certain raw socket interactions. Debugging and querying kernel state, such as listing rules with tools integrated into iptables, utilize Netlink dumps to retrieve current table configurations without altering them, allowing userspace to parse and display the kernel's internal state for verification. This mechanism ensures reliable feedback on rule applicability and chain traversal.

Tables and Chains

Built-in Tables

iptables organizes its rules into several built-in tables, each designed to handle specific aspects of packet processing within the Netfilter framework. The filter table is the default table used for general packet filtering decisions, containing built-in chains such as INPUT for incoming packets destined to system, FORWARD for packets being routed through the system, and OUTPUT for locally generated packets. This table primarily determines whether to accept, , or reject packets based on policies. The NAT table manages tasks, including source NAT (SNAT), destination NAT (DNAT), and masquerading, with built-in chains PREROUTING for initial translation on incoming packets, POSTROUTING for final translation on outgoing packets, and OUTPUT for locally generated packets requiring translation. It enables functionalities like and load balancing by modifying packet headers before routing decisions. The mangle table allows for low-level packet alteration, such as changing headers or marking packets for specialized , and operates across all Netfilter hooks with built-in chains PREROUTING, INPUT, FORWARD, OUTPUT, and POSTROUTING. Common uses include adjusting Time-to-Live () values or setting (TOS) bits to influence (QoS). The raw table is intended for configuring exemptions from the connection tracking system, helping to optimize performance by avoiding unnecessary stateful inspection, and includes built-in chains PREROUTING and OUTPUT. Packets can be marked here using the NOTRACK to bypass conntrack processing. The security table provides integration with SELinux for applying policies directly to network packets, featuring built-in chains INPUT, FORWARD, and OUTPUT, and is typically used in environments requiring fine-grained security labeling. It enforces security contexts on packets similar to how SELinux handles file access. While iptables supports the creation of custom tables through extension modules, such usage is rare and generally reserved for advanced or specialized implementations.

Chain Types and Traversal

In iptables, chains serve as ordered lists of rules that determine how packets are processed within specific tables, such as the filter table which handles packet acceptance or denial. Built-in chains are predefined and table-specific, providing default entry points for packet processing; for instance, the INPUT chain in the filter table processes packets destined for the local system, the FORWARD chain manages packets being routed through the system, and the OUTPUT chain deals with locally generated packets. These chains cannot be deleted and are invoked automatically based on the packet's path through the Netfilter hooks in the Linux kernel. User-defined chains, in contrast, allow administrators to create custom, modular sets for better organization and reusability. These are created using the -N option in the iptables command, such as iptables -N mychain, and can be up to 31 characters long, conventionally named in lowercase. Unlike built-in chains, user-defined chains are empty upon creation, can be deleted with -X if unused, and must be explicitly invoked from built-in chains to process packets. Packet traversal through chains follows a deterministic logic tied to the Netfilter framework's hook points, where packets enter chains in a predefined order based on their type and direction. Within any chain—built-in or user-defined—rules are evaluated sequentially from top to bottom until a matching rule is found or the end of the chain is reached. For example, an incoming packet destined for the local host first traverses the PREROUTING chains in the , mangle, and tables (in priority order), then proceeds to the INPUT chains in the mangle, , and security tables for processing and final acceptance decisions. This sequential evaluation ensures efficient processing, with the kernel stopping at the first match to apply the associated . If no matches within a , the chain's serves as the fallback , applicable only to built-in chains and typically set to ACCEPT (allowing the packet to proceed) or (silently discarding it). are configured using the -P option, such as iptables -P INPUT [DROP](/page/Drop), and determine the packet's fate when traversal reaches the chain's end without a match. For user-defined chains, there is no inherent ; instead, control returns to the calling chain to continue evaluation. The jump and return mechanisms enable dynamic between chains, enhancing without terminating packet processing prematurely. A 's target can specify -j chainname to jump to a user-defined , where traversal proceeds sequentially until a target is matched or the chain ends, at which point execution resumes immediately after the jumping in the original . For instance, a like iptables -A INPUT -j mychain would divert matching packets to mychain for specialized checks, with iptables -A mychain -j [RETURN](/page/Return) ensuring resumption in INPUT. If the end of a user-defined is reached without a , it behaves as an implicit , preventing infinite loops and maintaining orderly traversal.

Rules and Matching

Rule Structure

An iptables rule defines conditions for matching network packets and specifies the action to take if a match occurs. The fundamental syntax for adding a rule is iptables [-t table] -A chain rule-specification, where -t table optionally specifies the (defaulting to filter), -A appends the rule to the named , and rule-specification consists of zero or more match criteria followed by a . For example, the command iptables -A INPUT -s 192.168.1.0/24 -j DROP appends a rule to the INPUT that drops packets from the specified IP range. Key components of a rule include specification, specifiers, and the . The identifies the sequence of rules where the new rule is placed, such as built-in chains like INPUT or user-defined ones created via -N. specifiers, such as -s for source address (e.g., -s 192.168.1.0/24), -d for destination, or -p for protocol (e.g., -p [tcp](/page/TCP)), filter packets based on basic attributes; more complex conditions can be added using extension modules via -m matchname. The , specified with -j targetname (e.g., -j ACCEPT), determines the action for matching packets, such as accepting, dropping, or jumping to another . Rules are evaluated in the order they appear in a , so positioning affects packet processing. The -A option appends a rule to the end of the , while -I [chain](/page/Chain) [rulenum] inserts it at the beginning or a specific position (rulenum starting from 1), allowing precise control over evaluation sequence; -R [chain](/page/Chain) rulenum rule-specification replaces an existing rule at the given position without altering the overall order. Each rule maintains per-rule counters for packets and bytes processed, enabling monitoring of traffic volume. These counters can be viewed with iptables -L -v for verbose listing or reset atomically using -Z [chain [rulenum]], which zeros counters without interrupting rule evaluation. To ensure consistent rule application and avoid partial configurations during updates, iptables supports atomic operations through tools like iptables-restore, which loads an entire ruleset from a file in a single transaction, preventing intermediate states that could expose vulnerabilities. The -w [seconds] option provides a waiting mechanism for acquiring an exclusive lock during modifications, further aiding safe concurrent administration.

Packet Matching Criteria

Packet matching criteria in iptables define the conditions under which a packet is selected by a rule for further processing. These criteria form the selection logic within each rule, allowing administrators to based on packet attributes such as addresses, ports, protocols, and states. Basic matches operate directly on core packet headers, while extensions provide advanced capabilities through loadable modules. The fundamental matching options include source and destination IP addresses, specified using the -s or --source and -d or --destination flags, respectively, which can target individual hosts, , or negated ranges (e.g., -s 192.168.1.0/24 to match packets from a ). Similarly, input and output interfaces are matched with -i or --in-interface for incoming traffic and -o or --out-interface for outgoing, enabling interface-specific filtering (e.g., -i eth0 to process only packets arriving on a particular card). Port matching requires specifying the first with -p or --protocol (e.g., -p [tcp](/page/TCP)), which implicitly enables port-related options like --sport for source ports or --dport for destination ports (e.g., -p [tcp](/page/TCP) --dport 80 to match HTTP traffic). These basic criteria are inherent to the iptables command and do not require additional modules. Protocol-specific matches extend filtering for particular protocols. For TCP, the --tcp-flags option compares specified flags (e.g., , ) against a mask, such as --tcp-flags SYN,ACK SYN to detect packets for new connections, often abbreviated as --syn. ICMP packets are matched using --icmp-type, which identifies types like echo-request or destination-unreachable (e.g., --icmp-type echo-request). UDP matching mirrors TCP but lacks flag options, relying primarily on ports. These options activate only when the corresponding is selected via -p. Stateful matching leverages the connection tracking (conntrack) subsystem, invoked with the -m conntrack or legacy -m state module, to evaluate packets against connection states like NEW, ESTABLISHED, RELATED, or INVALID (e.g., -m state --state ESTABLISHED to allow return traffic in a stateful firewall). This module tracks connection tuples (source/destination IP, ports, protocol) and their lifecycle, enabling rules that permit bidirectional flows without explicit bidirectional specifications. Additional conntrack options include --ctstatus for statuses like EXPECTED or ASSURED, and --ctdir to distinguish original or reply directions. Iptables supports extensible matching through loadable modules, loaded via -m followed by the name, which augment the core criteria for complex scenarios. The multiport (-m multiport) allows matching up to 15 non-contiguous ports or ranges in a single rule (e.g., -m multiport --dports 22,80,443 for SSH, HTTP, and ), improving efficiency over multiple basic rules. The string (-m string) inspects packet payloads for patterns, supporting text or hex strings with algorithms like Boyer-Moore (--algo bm) and offsets (e.g., -m string --string "malware" --algo bm), useful for . Other notable extensions include addrtype for address categories (e.g., -m addrtype --dst-type LOCAL for traffic) and mac for layer-2 addresses (e.g., -m mac --mac-source 00:11:22:33:44:55). These modules are part of the Netfilter framework and must be available in the .

Targets and Actions

Standard Targets

In iptables, targets define the actions taken when a packet matches a rule in a chain. These include built-in targets (, , , ), which are part of the core netfilter framework and do not require extension modules, as well as common extension targets (such as and ) that provide additional functionality via kernel modules loaded automatically when referenced. They are specified using the -j or --jump option followed by the target name. The ACCEPT target permits the matching packet to continue traversing the current and, if applicable, proceed to subsequent hooks or chains in the netfilter processing path. Once ACCEPT is invoked, rule evaluation stops for that packet in the current , allowing it to follow the normal network stack behavior. This is the default outcome for allowing legitimate traffic. The DROP target silently discards the matching packet, preventing it from proceeding further in the network stack without notifying . This action terminates rule traversal immediately, making it suitable for blocking unwanted traffic without revealing the presence of a . For example, a rule might use -j DROP to discard packets from suspicious addresses. The REJECT target drops the matching packet and generates an ICMP error message back to , informing them of the rejection. This differs from DROP by providing feedback, which can aid in but may also leak information about the . It supports the --reject-with option to specify the ICMP type, such as tcp-reset for connections (sending a RST packet) or icmp-port-unreachable as the default for . An example rule is iptables -A INPUT -p tcp --dport 22 -j REJECT --reject-with tcp-reset. The RETURN target ends the evaluation of the current chain and resumes processing at the next rule in the calling (parent) chain, if any. In built-in chains, it effectively applies the chain's policy. This is useful in user-defined chains to exit early without a final decision, allowing higher-level chains to handle the packet. For instance, iptables -A MYCHAIN -j RETURN would return control after matching in a custom chain named MYCHAIN. The target passes the matching packet to a userspace application for further processing via the interface (using tools like libnetfilter_queue). This terminates rule traversal and is useful for custom handling outside the kernel. The target logs details of the matching packet to the kernel log (accessible via tools like dmesg or syslog) without terminating rule traversal, so subsequent rules are still evaluated. It includes options for : --log-prefix adds a string prefix (up to 29 characters) to log entries for identification; --log-level sets the syslog level (default is warning); --log-tcp-sequence logs sequence numbers; and --log-tcp-options logs options. A sample is iptables -A INPUT -p tcp --dport 80 -j LOG --log-prefix "HTTP: " --log-level info, which records HTTP traffic attempts. Chain policies establish the default action for packets that reach the end of a built-in chain (INPUT, OUTPUT, FORWARD) without matching any rule or after a RETURN from a sub-chain. Policies are set using the -P or --policy option and can only be ACCEPT or DROP for built-in chains; they do not support LOG or RETURN. For example, iptables -P INPUT DROP ensures unmatched incoming packets are dropped, enforcing a deny-by-default stance. Policies apply globally until changed and are crucial for secure configurations.

Extension Modules for Custom Actions

Extension modules in iptables, part of the Netfilter framework, allow users to implement specialized packet actions beyond the core built-in targets by loading modules that provide custom target behaviors. These extensions are particularly useful for tasks requiring advanced manipulation, such as address translation or enhanced logging, and are invoked through the -j or --[jump](/page/Jump) option in rule specifications. Target extensions include the SNAT and DNAT targets, which perform source and destination respectively, primarily used in the table's PREROUTING and POSTROUTING chains to rewrite packet addresses for outbound and inbound traffic. The MASQUERADE target serves a similar purpose to SNAT but is designed for dynamic IP environments, automatically using the outgoing interface's without specifying a fixed one, making it ideal for scenarios like home routers with varying external IPs. Modules for these extensions are loaded implicitly when a rule references them; for instance, specifying -j REJECT automatically loads the ipt_REJECT module if the kernel supports automatic module loading. This mechanism ensures that only necessary modules are brought into , optimizing performance. Custom targets, often provided by third-party extensions, enable niche functionalities such as the TARPIT target, which hijacks incoming connections from potential attackers by holding them open without consuming significant local resources, thereby slowing down scans or brute-force attempts. This is available through the xtables-addons project, an official extension package for Netfilter. Other notable examples include the ULOG target (deprecated and IPv4-specific; superseded by NFLOG), which forwarded packet data to userspace for advanced logging via the ulogd daemon, allowing for customizable output formats and integration with databases or analysis tools beyond the kernel's basic LOG target. The current NFLOG target provides similar userspace logging via , supporting both IPv4 and with options like --nflog-prefix and integration with ulogd or other daemons. The CLASSIFY target marks packets with a value for quality-of-service (QoS) purposes, enabling in the mangle table by assigning classes that queue disciplines can reference. Compatibility is critical, as extension modules must align with the running version; mismatches, such as using modules compiled for an older on a newer one, result in loading failures and error messages like "modprobe: FATAL" during rule application. Users must recompile or update modules when upgrading the to maintain functionality.

Configuration Tools

Core iptables Utility

The iptables utility serves as the primary for configuring and managing the Netfilter framework's packet ing capabilities in the . It enables administrators to define rules that inspect, modify, or drop network packets based on specified criteria, operating across multiple tables such as , , mangle, and raw. By default, iptables targets the table unless otherwise specified, allowing users to append, delete, list, or flush rules in built-in or user-defined chains without requiring a system reboot. This tool is essential for implementing stateful firewalls, , and directly from the . Core operations begin with commands for rule and chain manipulation. The -A or --append option adds one or more rules to the end of a specified , such as appending an ACCEPT rule for incoming HTTP traffic with iptables -A INPUT -p tcp --dport 80 -j ACCEPT. Conversely, -D or --delete removes rules either by matching their specification or by chain position number (starting from 1), as in iptables -D INPUT 1 to delete the first rule in the INPUT . For chain management, -L or --list displays all rules in a (or all chains if unspecified), often combined with -n for numeric output to skip DNS resolution, exemplified by iptables -L. The -N or --new-chain creates a custom user-defined , like iptables -N MYCHAIN, while -F or --flush clears all rules from a (or all chains), using iptables -F for a full reset. These subcommands follow the general syntax iptables [-t table] [command] [chain] [rule-specification] [options], where rule-specifications include match criteria (e.g., source IP with -s) and targets (e.g., -j DROP). Table selection is handled via the -t or --table option, which defaults to filter for standard packet filtering across chains like INPUT, FORWARD, and OUTPUT. Other tables include nat for network address translation in chains such as PREROUTING and POSTROUTING, mangle for packet alterations in prerouting and postrouting stages, and raw for exempting packets from connection tracking. An example is iptables -t nat -A PREROUTING -j DNAT --to-destination 192.168.1.100 to redirect traffic. For enhanced visibility, -v or --verbose outputs detailed information including interface names, rule options, and byte/packet counters during listings, as with iptables -L -v. The -x or --exact flag ensures counters display precise values without rounding to thousands, useful in iptables -L -v -x for accurate statistics. Additionally, -Z or --zero resets all counters in a chain (or all chains) to zero, often paired with -L for pre-reset snapshots, such as iptables -L -Z. These features provide granular control over firewall statistics without altering rules. Graphical and script-based frontends, such as ufw (which wraps iptables) or (which defaults to but supports an iptables backend), simplify complex rule management for non-expert users. The full syntax and additional subcommands, including -I for insertion and -R for replacement, are detailed in the official accessible via man iptables.

Graphical and Script-Based Frontends

Graphical and script-based frontends provide user-friendly abstractions over the core iptables utility, enabling easier configuration of rules without directly manipulating command-line syntax. These tools generate iptables commands from higher-level inputs, such as graphical interfaces or declarative scripts, making them suitable for administrators seeking simplified management. Among graphical user interfaces (GUIs), offers a GTK-based frontend for iptables, allowing users to configure rules and policies through an intuitive visual while providing . Developed as a dynamic tool, it supports comprehensive iptables features like packet filtering and supports quick setup for incoming and outgoing connections. However, has been discontinued, with its last significant updates occurring around 2010, limiting its compatibility with modern distributions. Shorewall serves as a script-based that simplifies iptables rule management through zone-based files. This approach abstracts complex iptables chains into readable files, facilitating multi-interface deployments like those for local networks and internet gateways. Shorewall generates iptables rules dynamically from these files, ensuring flexibility for advanced zoning without manual command invocation. Script-based frontends like Ferm employ a declarative to define iptables rules in a structured, brace-enclosed that compiles into kernel-level commands. This reads files and invokes iptables to insert rules, supporting modular extensions for and while avoiding repetitive manual scripting. Ferm's emphasizes readability, using keywords for protocols, ports, and actions, which reduces errors in maintaining complex rulesets. UFW, or Uncomplicated Firewall, acts as a backend-agnostic frontend that primarily leverages iptables for rule enforcement on Ubuntu and Debian systems, offering simple commands like ufw allow to manage host-based firewalls. It abstracts iptables complexity into a streamlined interface, automatically handling IPv4 and IPv6 rules while providing status checks and application profile integration. UFW's design prioritizes ease for non-experts, translating high-level directives into equivalent iptables chains. Web-based tools, such as the Webmin Linux Firewall module, enable browser-driven iptables configuration through a centralized dashboard accessible via HTTP. This module supports editing rules for filtering, , and masquerading, with visual representations of chains and application of changes to the running . Webmin's integrates with , allowing remote without local CLI . These frontends offer key advantages, including abstraction that lowers the barrier for non-experts by hiding iptables' verbose syntax, though they may not cover all extension modules or edge cases available in direct usage. For instance, GUIs like and script tools like UFW promote rapid prototyping and error reduction through validation, but users should verify generated rules for completeness. In modern contexts, tools like provide an alternative with iptables backend compatibility, allowing legacy rule translation while defaulting to for enhanced performance; this integration supports gradual migration from iptables-centric frontends.

Advanced Usage

Network Address Translation (NAT)

Network Address Translation (NAT) in iptables enables the modification of IP addresses and ports in packet headers to facilitate connectivity between private and public networks, as implemented in the netfilter framework of the Linux kernel. The NAT functionality operates within a dedicated NAT table, distinct from the filter and mangle tables, where rules are applied to alter packet headers at specific points in the packet processing path. This table includes three built-in chains: PREROUTING, OUTPUT, and POSTROUTING, but the primary chains for inbound and outbound translation are PREROUTING and POSTROUTING, respectively. The PREROUTING chain handles Destination NAT (DNAT), which modifies the destination IP address and optionally the port of incoming packets before the routing decision is made. This occurs early in the netfilter hook processing, allowing redirection of traffic to internal hosts without altering the original packet's source. For example, to forward incoming TCP traffic destined for port 80 on the firewall to an internal server at 192.168.1.100 on port 8080, the following rule can be applied:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.1.100:8080
This command appends a rule to the PREROUTING chain in the NAT table, targeting TCP packets with destination port 80 and redirecting them accordingly. In contrast, the POSTROUTING chain manages Source NAT (SNAT), which alters the source IP address and port of outgoing packets after routing but before transmission. SNAT is commonly used to map multiple internal IP addresses to a single public IP, ensuring return traffic is routed back through the firewall. A variant, MASQUERADE, performs dynamic SNAT by using the current IP address of the outgoing interface, making it suitable for environments with dynamically assigned IPs, such as dial-up connections. For instance, to masquerade all outbound traffic from the 192.168.1.0/24 subnet via the eth0 interface:
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
This rule applies to packets with source IPs in the specified subnet exiting through eth0, replacing the source with the interface's IP. Stateful NAT in iptables relies on the netfilter connection tracking subsystem, provided by the nf_conntrack kernel module, to maintain mappings for bidirectional traffic flows. Without connection tracking, NAT operations cannot ensure that reply packets are properly translated and routed, leading to dropped packets as the NAT code requires valid tracking information for stateful modifications. The nf_conntrack module tracks the state of connections, storing tuples of source/destination addresses and ports to apply consistent translations across the entire connection. Common use cases for iptables NAT include port forwarding via DNAT to expose internal services to external clients, load sharing by distributing DNAT rules across multiple backend servers for basic traffic balancing, and hiding internal networks through SNAT or MASQUERADE to prevent direct exposure of private IPs. These capabilities allow a single public IP to serve multiple internal devices, conserving while enhancing by obscuring the internal . For related packet alterations outside of pure address translation, the mangle table can be referenced briefly, but NAT focuses primarily on address and port changes.

Logging and Monitoring

Iptables provides logging capabilities through the target, which records details of matching packets without terminating the chain, allowing continued rule traversal. When invoked with the -j option, it sends log messages to the kernel's logging facilities, typically output to /var/log/kern or via depending on system configuration. Key options include --log-prefix to prepend a custom string (up to 29 characters) for easy identification, such as "Dropped: ", and --log-level to set the priority level (e.g., 4 for ). Additional flags like --log-tcp-sequence enable inclusion of sequence numbers, while --log-uid logs the process if applicable. For example, a like iptables -A INPUT -j --log-prefix "Dropped: " --log-level 4 logs incoming packets at warning level with the specified prefix. For userspace logging, the NFLOG target is the current standard (IPv4 and IPv6), providing packet logging to userspace via Netlink for integration with daemons. It supersedes the deprecated ULOG target (IPv4-only, end-of-life since ~2012), which offered similar functionality but is no longer recommended or supported in modern ulogd versions. NFLOG multicasts packet data via Netlink to userspace processes, with options such as --nflog-prefix for message prefixes (up to 32 characters), --nflog-group to specify the Netlink group (0-31), and --nflog-range to limit copied packet bytes. Ulogd2, the current userspace daemon (as of 2025), receives NFLOG messages and supports outputs to formats like SQL databases (e.g., MySQL, PostgreSQL) or text files (CSV, XML), enabling structured analysis of security events or traffic accounting. For instance, iptables -A INPUT -j NFLOG --nflog-prefix "HTTP: " --nflog-group 2 pairs with ulogd2 to parse and store HTTP-related logs efficiently. Legacy ULOG rules may still function with older kernels and ulogd1.x, but migration to NFLOG is advised for compatibility. Monitoring rule effectiveness relies on iptables' built-in counters, accessible via the -L -v -n command, which lists rules in numeric format with verbose details including packet and byte counts for each rule. These counters increment for matched packets, providing insights into volumes and rule hits without external tools. The -v displays cumulative pkts/bytes (e.g., with K/M/G suffixes for scale), aiding in identifying high-traffic rules or potential bottlenecks. To complement iptables counters, tools like vnStat can monitor overall traffic statistics from data, offering daily, monthly, or top-day summaries that contextualize activity. While not directly tied to iptables rules, vnStat's lightweight logging helps correlate aggregated usage with rule-based observations. prevents log inundation during bursts, using the --log-limit option (e.g., 1/s for one message per second) with a algorithm; exceeding the limit suppresses further logs until replenished. This is essential for rules like those dropping invalid packets, ensuring logs remain actionable. For deeper analysis, iptables logs can be examined alongside packet captures from or , enabling forensic review of logged traffic patterns. , for example, filters captures by interface or protocol to match logged events, while Wireshark provides graphical dissection for complex investigations. Logging in NAT contexts, such as PREROUTING chains, similarly aids in auditing address translations.

Management and Persistence

Saving and Restoring Rules

Iptables rules configured in memory are lost upon system reboot unless explicitly saved to persistent . The primary tools for saving and restoring these rules are iptables-save and iptables-restore, which handle the dumping and loading of rule sets in a compatible format. The iptables-save command dumps the current contents of all iptables tables to standard output in a human-readable, parseable format, which can be redirected to a file for persistence. For example, running iptables-save > /etc/iptables.rules saves the rules to /etc/iptables.rules. This output includes headers, definitions, and rules, supporting both IPv4 (iptables) and (ip6tables) variants. The format is designed for direct consumption by iptables-restore, ensuring compatibility across versions and extensions. Options like -c preserve counters, and -M specifies the extension module loading mechanism. Conversely, iptables-restore reads rule data from standard input or a specified file to rebuild the tables, supporting features such as flushing existing s before loading (-f option) and conditional loading based on table names (-n for numeric output or -t for specific tables). For instance, iptables-restore < /etc/iptables.rules restores the saved configuration. The tool processes the input sequentially, applying rules atomically where possible, and includes options like --test for syntax validation without applying changes, allowing safe verification of rule files. Binary formats are not natively supported, but the text-based output remains efficient for most use cases. Distribution-specific mechanisms automate the persistence of these saves across reboots. On and systems, the iptables-persistent package (part of the netfilter-persistent suite) integrates with the init system, prompting for rule saving during installation and loading them via hooks in /etc/network/if-pre-up.d/iptables or services. Rules are typically stored in /etc/iptables/rules.v4 and /etc/iptables/rules.v6. In and derivatives like , the iptables-services package manages persistence by saving rules to /etc/sysconfig/iptables (or /etc/sysconfig/ip6tables for ) using service iptables save, with the init script or unit (iptables.service) restoring them on boot. To ensure reliability, automation often involves init scripts (e.g., SysV init) or systemd units that invoke iptables-restore early in the boot process, such as in the network-pre.target for systemd. These scripts can include error handling to prevent boot failures if rules are malformed. Best practices for managing saves emphasize validation to avoid misconfigurations. After saving, compare the output file against the current runtime rules using diff (e.g., iptables-save | diff - /etc/iptables.rules) to detect discrepancies. Additionally, use iptables-restore --test < /etc/iptables.rules to simulate loading without modification, catching syntax errors or incompatible extensions. Regular backups of rule files and testing restores in a non-production environment further mitigate risks.

Integration with System Services

Iptables integrates seamlessly with various system services and tools within the ecosystem, enabling dynamic management, , deployments, , and of firewall rules. This integration allows administrators to leverage iptables capabilities alongside higher-level abstractions for more efficient and scalable configurations. , a dynamic daemon commonly used in distributions like and , primarily employs the backend (default since version 0.6.3 in 2018) for rule management but supports an iptables backend for compatibility. The direct interface permits services and applications to insert raw iptables, ip6tables, or ebtables rules directly into the configuration during runtime. With the iptables backend, these rules are applied after firewalld's internal top-level rules. However, with the backend, iptables rules via the direct interface operate in a dual-firewall environment, where both iptables and process packets; iptables ACCEPT rules may still be rejected by subsequent rules, potentially leading to unexpected behavior or conflicts. For seamless coexistence of iptables scripts with firewalld's zone-based policies, selecting the iptables backend is recommended, though this may limit access to nftables-specific features. In containerized environments, relies on iptables to enforce network policies across network namespaces, particularly for bridge networks and port mappings. Although primarily uses iptables, experimental support was introduced in version 29.0.0 (2024) as an alternative backend. Engine automatically generates iptables rules in the host's network namespace to route between containers and external networks, handle DNS , and publish container ports to the host. This includes creating dedicated chains like DOCKER and DOCKER-USER, where the latter allows custom rules to be inserted before Docker's default forwarding logic, enhancing and for containerized applications. By manipulating iptables, ensures that containers operate in isolated namespaces while maintaining connectivity as defined by the user's configuration. On cloud platforms like AWS, iptables functions as a host-level on EC2 instances, complementing the external controls provided by Security Groups. Security Groups operate as virtual firewalls at the level, filtering inbound and outbound traffic based on defined rules without modifying the instance's iptables tables. Administrators can thus layer iptables rules on EC2 instances for additional , such as stateful or custom logic, that extends beyond the stateless nature of Security Groups. This dual approach is common in production deployments to achieve defense-in-depth, where Security Groups handle broad access controls and iptables manages intra-instance or application-specific filtering. Configuration orchestration tools like and incorporate modules specifically designed for declarative management of iptables rules, streamlining deployment across large-scale infrastructures. The built-in iptables module enables the creation, modification, and verification of rules in the kernel's tables, supporting actions like appending, inserting, or flushing chains while ensuring idempotent application. Similarly, the Puppet Labs module abstracts iptables operations into resources that generate rules in iptables-restore format, allowing rules to be defined in Puppet manifests and automatically applied or persisted on managed nodes. These modules support variables for dynamic rule generation, making them ideal for environment-specific configurations in automated workflows. For monitoring, iptables metrics can be exposed to stacks like using dedicated exporters that parse rule counters and . The iptables_exporter, for example, scrapes data from iptables-save output to provide Prometheus-compatible metrics on packet and byte counts per rule, enabling visualization of activity in tools like . This integration allows operators to track anomalies, such as unexpected spikes, and correlate them with events for proactive security management.

Security Considerations

Best Practices for Firewall Rules

When configuring iptables rules, adhering to the principle of least privilege is fundamental to enhancing security by minimizing exposure to unauthorized access. This involves setting a default policy of DROP for input, output, and forward chains to block all traffic unless explicitly permitted, thereby ensuring that only necessary connections are allowed. For instance, administrators can implement this by executing commands such as iptables -P INPUT DROP and iptables -P FORWARD DROP, followed by targeted ACCEPT rules for required services like SSH on port 22: iptables -A INPUT -p tcp --dport 22 -j ACCEPT. This approach prevents unintended traffic from traversing the firewall, reducing the attack surface significantly. Proper ordering is critical to avoid inefficiencies and gaps, as iptables evaluates sequentially from top to bottom until a match is found. Specific should precede more general ones to prevent broader from shadowing narrower permissions; for example, a allowing from a trusted (e.g., iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT) must appear before a catch-all ACCEPT for established connections to ensure granular control. Misordering can lead to unintended allowances, so reviewing the chain with iptables -L -v -n --line-numbers helps verify the sequence. Leveraging stateful inspection through the connection tracking (conntrack) module enables efficient handling of bidirectional traffic without redundant rules for return packets. By including rules like iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT early in the chain, iptables can permit responses to outbound connections automatically, supporting protocols such as while maintaining security for stateless ones like when combined with conntrack. This practice optimizes performance and simplifies rule sets by focusing on new incoming connections only. Testing rules thoroughly before deployment mitigates risks of locking out legitimate access or creating vulnerabilities. Best practices include validating syntax with iptables-restore --test /path/to/ruleset in a non-production environment, simulating traffic using tools like nc (netcat) or hping3 to verify behavior, and incorporating temporary LOG rules (e.g., iptables -A INPUT -j LOG --log-prefix "TEST: ") to monitor matches without altering policy. Once confirmed, rules can be flushed and reloaded safely. Documenting rules enhances maintainability and , particularly in complex environments. The -m comment extension allows inline annotations, such as iptables -A INPUT -p tcp --dport 80 -m comment --comment "Allow HTTP from [web](/page/Web) clients" -j ACCEPT, which persist when saving rules with iptables-save. This facilitates auditing and without relying solely on external scripts or files.

Common Vulnerabilities and Mitigations

One common misconfiguration in iptables involves unintended exposure of the interface, where an ACCEPT policy on the interface without proper restrictions can allow local exploits or spoofed traffic from non- sources to reach 127.0.0.0/8 addresses, potentially enabling or unauthorized access to local services. To mitigate this, explicitly configure rules to accept traffic only on the interface while dropping any 127.0.0.0/8 traffic arriving on other interfaces, such as using iptables -A INPUT -i [lo](/page/Lo) -j ACCEPT, iptables -A OUTPUT -o [lo](/page/Lo) -j ACCEPT, and iptables -A INPUT -s 127.0.0.0/8 ! -i [lo](/page/Lo) -j [DROP](/page/Drop). Fragmentation issues arise when iptables rules fail to account for IP fragments, as non-first fragments lack higher-layer information and may bypass standard filtering, leading to incomplete packet inspection and potential exploitation of reassembly vulnerabilities. Administrators should use the -f match extension to explicitly handle fragments, such as dropping second and further fragments with iptables -A INPUT -f -j DROP unless fragmentation is required for specific traffic like large packets. Denial-of-service (DoS) risks from connection tracking table overflow occur when the nf_conntrack table fills due to high-volume connections, causing legitimate packets to be dropped and leading to service disruptions, often exploited in or UDP amplification attacks. Mitigation involves tuning the table size by increasing /proc/sys/net/netfilter/nf_conntrack_max (e.g., to 262144 for high-load systems) and usage with cat /proc/sys/net/netfilter/nf_conntrack_count, while also reducing timeouts via parameters like net.netfilter.nf_conntrack_tcp_timeout_established=3600. Gaps in configuration, such as neglecting ip6tables rules while focusing solely on iptables, leave systems vulnerable to IPv6-specific attacks like neighbor discovery spoofing or tunneling bypasses, as IPv6 traffic may route unimpeded even if IPv4 is firewalled. If is enabled (checked via sysctl net.ipv6.conf.all.disable_ipv6=0), configure parallel ip6tables rules mirroring iptables policies, or disable globally with sysctl net.ipv6.conf.all.disable_ipv6=1 in /etc/sysctl.conf to avoid dual-stack risks. Post-2020 attacks on packages, exemplified by the backdoor (CVE-2024-3094), have compromised dependencies in distributions, such as those affecting , potentially inserting malicious code during builds to enable remote code execution. To mitigate, verify package integrity using tools like rpm -V iptables on RPM-based systems or dpkg --verify iptables on Debian-based ones, and source packages from official repositories with signature checks enabled. Recent kernel-level vulnerabilities in netfilter components, such as CVE-2024-42270 (a dereference in iptable_nat_table_init fixed in 6.10.7 as of September 2024), can lead to denial of service or system crashes when initializing tables. Mitigation requires updating to a patched version and monitoring for related CVEs via official security advisories.

Alternatives and Future

Transition to nftables

was introduced in version 3.13, released in January 2014, as a successor to iptables, providing a unified configuration syntax for packet filtering across IPv4, , ARP, and bridge protocols within the Netfilter framework. This integration eliminates the need for separate tools like iptables, ip6tables, arptables, and ebtables, streamlining administration through a single userspace utility called nft. To facilitate migration from iptables, tools such as iptables-translate and iptables-restore-translate were developed to convert existing rulesets. The iptables-translate utility processes individual iptables or ip6tables commands, outputting equivalent syntax; for instance, an iptables rule like -A INPUT -p [tcp](/page/TCP) --dport 22 -j ACCEPT translates to nft add rule [ip](/page/IP) filter INPUT [tcp](/page/TCP) dport 22 accept. Similarly, iptables-restore-translate reads a complete ruleset in iptables-save format and generates nftables-compatible output, which can then be loaded via the nft command, enabling batch conversions for saved configurations. These tools support text-based translation without modifying the original ruleset, though they require manual verification for accuracy. nftables offers several advantages over iptables, including improved performance through more efficient kernel-space rule matching and reduced overhead from its generalized architecture. It supports atomic updates, allowing entire rulesets to be loaded or replaced transactionally without partial application risks, which enhances reliability during configuration changes. Additionally, the single nft binary simplifies deployment and maintenance compared to iptables' multiple binaries. Despite these benefits, migrating to presents challenges, particularly due to syntax differences; for example, iptables chains are translated to regular chains in , while base chains (hooked directly to Netfilter) require explicit definition for , and forward hooks. Translations may be incomplete for complex extensions, such as string matching rules, which can result in commented or unsupported output, necessitating manual adjustments. Policy settings, like default drop actions, are sometimes omitted in automated conversions, requiring administrators to verify and supplement the generated rules. Adoption of nftables as the default firewall backend has progressed across major distributions. Fedora 29, released in 2018, switched firewalld to use nftables by default, providing backward compatibility via the iptables-nft package. Ubuntu followed in version 20.10 (2020), making nftables the default backend while retaining iptables compatibility through packages like iptables-nftables-compat, which allows legacy syntax to interact with the nftables kernel infrastructure. This package ensures seamless operation for existing scripts and tools during the transition period.

Comparison with Other Firewalls

Iptables employs a rigid table-and-chain model for organizing rules, where packets traverse predefined chains within tables like or , which can lead to verbose configurations for complex scenarios. In contrast, introduces maps and sets to group related rules more efficiently, enabling concise expressions for dynamic elements such as IP address lists or port ranges, reducing rule redundancy and improving maintainability. Performance benchmarks indicate scales better under load; for instance, it maintains consistent throughput as custom chains increase, unlike iptables, which experiences linear degradation in packet processing speed. Compared to and XDP, iptables operates within the netfilter framework at various hook points in the kernel's network stack, introducing overhead from rule traversal and connection tracking. /XDP allows programmatic packet filtering directly at the network interface ingress using (XDP), bypassing netfilter entirely for sub-microsecond latencies in high-throughput environments. This enables ultra-low latency applications, such as those in , where eBPF-based filtering achieves up to 10 times higher packets-per-second rates than iptables for deny-all rules on streams matching few criteria. UFW and firewalld provide higher-level abstractions atop iptables or , prioritizing ease of use for desktop and server administrators over fine-grained control. UFW simplifies rule management with a straightforward for common tasks like allowing SSH or HTTP, translating them into underlying iptables rules without exposing chain complexities. adds dynamic zone-based management for runtime changes, such as switching profiles for wired versus wireless interfaces, but sacrifices iptables' granular matching on packet headers or state for predefined service profiles. These tools suit non-expert users but limit customization compared to direct iptables manipulation. Outside Linux, OpenBSD's pf firewall processes rules sequentially in a single configuration file, avoiding iptables' multi-table navigation for simpler syntax and faster parsing, while integrating ALTQ for built-in Quality of Service (QoS) queuing to prioritize traffic classes like voice over data. Windows Firewall, conversely, emphasizes enterprise integration through Group Policy Objects (GPO) for centralized rule deployment across domains, supporting inbound/outbound profiles with application-aware filtering but lacking iptables' protocol-level extensibility via modules. As of 2025, iptables remains suitable for Linux systems with entrenched scripts or extensions like certain legacy netfilter modules not fully ported to , ensuring compatibility without migration overhead in stable environments.

References

  1. [1]
    The netfilter.org "iptables" project
    iptables is the userspace command line program used to configure the Linux 2.4.x and later packet filtering ruleset. It is targeted towards system ...
  2. [2]
    iptables(8) - Linux manual page - man7.org
    Iptables and ip6tables are used to set up, maintain, and inspect the tables of IPv4 and IPv6 packet filter rules in the Linux kernel.
  3. [3]
    Linux 2.4 NAT HOWTO: Introduction - Netfilter.org
    In Linux 2.4, an infrastructure for mangling packets was introduced, called `netfilter'. A layer on top of this provides NAT, completely reimplemented from ...Missing: iptables | Show results with:iptables
  4. [4]
    2.8.9. IPTables | Security Guide | Red Hat Enterprise Linux | 6
    This chapter focuses on packet filtering basics, explains various options available with iptables commands, and explains how filtering rules can be preserved ...
  5. [5]
    netfilter/iptables project homepage - The netfilter.org project
    The netfilter project is a community-driven collaborative FOSS project that provides packet filtering software for the Linux 2.4.x and later kernel series.Iptables project · Projects · About · Documentation about the...Missing: introduction | Show results with:introduction
  6. [6]
    About the netfilter/iptables project
    The netfilter project was founded by Paul "Rusty" Russell to re-design and to heavily improve the previous Linux 2.2.x ipchains and Linux 2.0.x ipfwadm systems.Missing: origins | Show results with:origins
  7. [7]
    Man page of IPTABLES - IP sets - Netfilter.org
    Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet selection framework in iptables, then wrote the mangle table, the owner match, the ...<|separator|>
  8. [8]
    The History of Linux - PCL Publications
    – 2001: A pivotal moment in the Linux kernel came with version 2.4, released on 4th January. Version 2.4 contained support for USB, PC Cards, ISA Plug and ...<|separator|>
  9. [9]
    Chapter 18. iptables | Reference Guide | Red Hat Enterprise Linux | 4
    This chapter focuses on packet filtering basics, defines the differences between ipchains and iptables, explains various options available with iptables ...<|control11|><|separator|>
  10. [10]
    nftables vs iptables Linux Firewall Setup - zenarmor.com
    Oct 7, 2025 · iptables has been the main firewall tool for Linux for about 20 years, since it was first included to the Linux kernel in 2001. It took the ...
  11. [11]
    The Netfilter HomePage: 1.2
    The Netfilter HomePage: 1.2. This version requires 2.4.0-test9 or above. Bugs Fixed from 1.1.2: Now default installs into /usr/local/sbin, ...Missing: changelog | Show results with:changelog
  12. [12]
    '[ANNOUNCE] Release of iptables 1.4.0 final' - MARC
    Dec 22, 2007 · ... release candidate which strongly improves IPv6 support. Please, upgrade! Version 1.4.0 can be obtained from: http://www.netfilter.org ...Missing: notes arptables
  13. [13]
    NFTables IPTables-Replacement Queued For Linux 3.13 - Phoronix
    Oct 19, 2013 · This new nftables system is set to be merged now into the Linux 3.13 kernel. NFTables has been in development for years and to replace IPTables ...Missing: deprecated | Show results with:deprecated
  14. [14]
    iptables: The two variants and their relationship with nftables
    Aug 18, 2020 · The iptables-nft command uses the newer nftables kernel API but reuses the legacy packet-matching code. As a result, you get the following ...Missing: 2019-2021 | Show results with:2019-2021
  15. [15]
    Releases of the iptables project - Netfilter.org
    The latest iptables release is 1.8.11 (2024-11-08), with 1.8.10 (2023-10-10) and 1.8.9 (2023-01-12) also listed.
  16. [16]
    Linux netfilter Hacking HOWTO: Information for Programmers
    ip_tables Data Structures. For convenience, the same data structure is used to represent a rule by userspace and within the kernel, although a few fields are ...Ip_tables Data Structures · Ip_tables From Userspace · Inside The Kernel
  17. [17]
    Linux netfilter Hacking HOWTO: Netfilter Architecture
    Netfilter is a series of hooks in the protocol stack. Packets traverse pre-routing, routing, local in, forward, and post-routing hooks. Kernel modules can ...Missing: components | Show results with:components
  18. [18]
    config_ip_nf_filter - kernelconfig.io
    CONFIG_IP_NF_FILTER -iptable_filter.ko- Packet filtering defines a table `filter', which has a series of rules for simple packet filtering at local input, ...
  19. [19]
    Benchmarking nftables - Red Hat Developer
    Apr 11, 2017 · The results are obvious: While iptables performance suffers quite linearly with number of custom chains, nftables performance scales perfectly.Missing: bloat | Show results with:bloat
  20. [20]
    Introduction to Netlink - The Linux Kernel documentation
    Netlink is an ioctl() replacement using sockets for communication, allowing for easy addition or extension of arguments. It uses a TLV format.
  21. [21]
    netlink(7) - Linux manual page - man7.org
    Netlink is used to transfer information between the kernel and user-space processes. It consists of a standard sockets-based interface for user space processes ...
  22. [22]
  23. [23]
  24. [24]
    capabilities(7) - Linux manual page - man7.org
    CAP_NET_ADMIN Perform various network-related operations: • interface configuration; • administration of IP firewall, masquerading, and accounting; • modify ...
  25. [25]
    Linux 2.4 Packet Filtering HOWTO: Using iptables - Netfilter.org
    One powerful feature which iptables inherits from ipchains is the ability for the user to create new chains, in addition to the three built-in ones (INPUT, ...Missing: introduction | Show results with:introduction
  26. [26]
    iptables(8) - Linux man page - Die.net
    Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Several different tables may be defined. Each .
  27. [27]
  28. [28]
    Man page of iptables-extensions - IP sets - Netfilter.org
    This module matches packets based on their address type. Address types are used within the kernel networking stack and categorize addresses into various groups.
  29. [29]
    packet-filtering-HOWTO.txt - Netfilter.org
    A target extension consists of a kernel module, and an optional extension to iptables to provide new command line options. There are several extensions in the ...
  30. [30]
    Netfilter Extensions HOWTO: New netfilter targets
    In this section, we will attempt to explain the usage of new netfilter targets. The patches will appear in alphabetical order.
  31. [31]
    UFW - Community Help Wiki - Ubuntu Documentation
    Sep 27, 2023 · UFW is Ubuntu's default firewall tool, designed to ease iptables configuration and create user-friendly IPv4 or IPv6 host-based firewalls.Missing: backend | Show results with:backend
  32. [32]
    Firestarter - Community Help Wiki
    Sep 4, 2017 · Firestarter is an application which provides a graphical interface for quickly configuring firewall rules and settings (policies).
  33. [33]
    26. firestarter and iptables: Setting Up a Firewall - A Practical Guide ...
    The firestarter utility is a user-friendly, graphical front-end for iptables; iptables builds and manipulates network packet filtering (page 1052) rules in ...
  34. [34]
    An Introduction to the Shorewall Firewall Tool - Linux.com
    Feb 3, 2017 · Shorewall is an open source firewalling tool that not only makes the task of network security easier, it also allows for much easier handling of zones.
  35. [35]
    ferm - for Easy Rule Making
    ferm is a tool to maintain complex firewalls, without having the trouble to rewrite the complex rules over and over again. ferm allows the entire firewall rule ...Missing: declarative | Show results with:declarative
  36. [36]
    MaxKellermann/ferm: ferm is a frontend for iptables - GitHub
    The ferm(1) man page provides extensive documentation about the ferm syntax. To get started, try one of the example files, and modify it for your needs. If ...Missing: declarative | Show results with:declarative
  37. [37]
    How to Use UFW (Uncomplicated Firewall) | Baeldung on Linux
    Mar 18, 2024 · The Uncomplicated Firewall (UFW) is a command-line firewall abstraction layer that automatically uses either iptables or nftables as a back-end firewall.
  38. [38]
    Linux Firewall | Webmin
    Sep 10, 2023 · This page covers the process of setting up and configuring a Linux firewall with Webmin and iptables.Intro · The module · Setting up network address... · Setting up a transparent proxy
  39. [39]
    Top 5 Best Linux Firewalls - The Geek Stuff
    Feb 15, 2010 · Gufw is a graphical interface for the UFW that is used on Ubuntu distribution. It is very intuitive and easy to manage your iptables firewall ...<|separator|>
  40. [40]
    GUI for iptables? - Ask Ubuntu
    Jul 28, 2010 · Firestarter has always worked well in my opinion. It supports a robust GUI and supports all options of iptables.
  41. [41]
    nftables backend - Firewalld
    Jul 24, 2018 · The nftables backend has feature parity with the old iptables backend. That means any issues or missing functionality will be treated as ...Missing: compatibility | Show results with:compatibility
  42. [42]
    Chapter 40. Using and configuring firewalld - Red Hat Documentation
    The nf_tables API provides backward compatibility so that scripts that use iptables commands still work on Red Hat Enterprise Linux. For new firewall scripts, ...
  43. [43]
    Linux 2.4 NAT HOWTO
    **Summary of NAT Tables, Chains, DNAT, SNAT, MASQUERADE from NAT-HOWTO**
  44. [44]
    Linux 2.4 NAT HOWTO: Controlling What To NAT - Netfilter.org
    The two chains are called PREROUTING (for Destination NAT, as packets first come in), and POSTROUTING (for Source NAT, as packets leave). The third (OUTPUT) ...
  45. [45]
    Linux 2.4 NAT HOWTO: The Two Types of NAT
    ### Summary of NAT in Netfilter Hooks and Connection Tracking
  46. [46]
    Linux 2.4 NAT HOWTO: Saying How To Mangle The Packets
    You want to do Source NAT; change the source address of connections to something different. This is done in the POSTROUTING chain, just before it is finally ...
  47. [47]
    netfilter/iptables FAQ: Problems at runtime
    This message is printed by the NAT code. It drops packets, because in order to do NAT it has to have valid connection tracking information.
  48. [48]
    The netfilter.org "ulogd" project
    ulogd is a userspace logging daemon for netfilter/iptables related logging. This includes per-packet logging of security violations, per-packet logging for ...
  49. [49]
    vnStat - a network traffic monitor for Linux and BSD - Humdi.net
    Oct 21, 2018 · vnStat is a console-based network traffic monitor for Linux and BSD that logs network traffic using kernel statistics, without sniffing traffic.
  50. [50]
    iptables-save(8) - Linux manual page - man7.org
    iptables-save and ip6tables-save are used to dump the contents of IP or IPv6 Table in easily parseable format either to STDOUT or to a specified file. -M, -- ...
  51. [51]
  52. [52]
    iptables-restore(8): Restore IP Tables - Linux man page - Die.net
    iptables-restore is used to restore IP Tables from data specified on STDIN. Use I/O redirection provided by your shell to read from a file.Missing: documentation | Show results with:documentation
  53. [53]
    Debian -- Details of package iptables-persistent in sid
    netfilter-persistent is a loader for netfilter configuration using a plugin-based architecture. This package contains the iptables and ip6tables plugins. Tags: ...
  54. [54]
    2.8.9.3. Saving IPTables Rules | Red Hat Enterprise Linux | 6
    For netfilter rules to persist through a system reboot, they need to be saved. To save netfilter rules, type the following command as root:.
  55. [55]
    How to save iptables firewall rules permanently on Linux - nixCraft
    Jan 24, 2025 · Explains how to save and restore iptables rules permanently on Debian/Ubuntu Linux or CentOS/RHEL using config files and persistent config.
  56. [56]
    How to make iptables persistent after reboot on Linux - LinuxConfig
    Sep 21, 2025 · In this tutorial you will learn: How to install iptables-persistent package on DEB distros; How to install iptables-services package on RPM ...
  57. [57]
    What best practices exist for writing iptables rules?
    Jun 14, 2024 · Issue. What best practices exist for writing iptables rules? How to write a good efficient firewall ruleset?
  58. [58]
    Best practices: iptables - Major Hayden
    Apr 12, 2010 · All iptables chains have a default policy setting. If a packet doesn't match any of the rules in a relevant chain, it will match the default ...
  59. [59]
    2.8.7. IPTables and Connection Tracking - Red Hat Documentation
    You can use the stateful functionality of iptables connection tracking with any network protocol, even if the protocol itself is stateless (such as UDP).Missing: best practices
  60. [60]
    How to add comments to iptables rules on Linux - nixCraft
    Apr 2, 2023 · You can add comments to iptables using the -m comment --comment "COMMENT TEXT" syntax. They can be instrumental in understanding firewall rules.Missing: documenting | Show results with:documenting
  61. [61]
    ip_conntrack or nf_conntrack : table full, dropping packet
    Aug 7, 2024 · Packet drops on this system for connections using ip_conntrack or nf_conntrack iptables modules. Messages seen in /var/log/messages on the ...
  62. [62]
    Reported Supply Chain Compromise Affecting XZ Utils Data ... - CISA
    Mar 29, 2024 · XZ Utils is data compression software and may be present in Linux distributions. The malicious code may allow unauthorized access to ...
  63. [63]
    The netfilter.org "nftables" project
    Using maps and concatenations, you can structure your ruleset to reduce the number of rule inspections to find the final action on the packet to the bare ...
  64. [64]
    Linux_3.13 - Linux Kernel Newbies
    This release includes nftables, the successor of iptables, a revamp of the block layer designed for high-performance SSDs, a power capping framework.
  65. [65]
  66. [66]
    Migrating my iptables setup to nftables - Red Hat Developer
    Jan 10, 2017 · The goal was to replace the existing iptables setup, ideally without any drawbacks. The following essay will guide you through what I have done in order to ...
  67. [67]
    iptables string rules translation to nftables
    Jun 24, 2021 · I am able to covert the rules from iptable to nftable but the string based rules which were in place in iptable are commented in nftables after translation.
  68. [68]
    Firewalld: The Future is nftables - Red Hat Developer
    Aug 10, 2018 · Existing Fedora installs will automatically be upgraded to the nftables backend when they upgrade to Fedora 29. Unfortunately firewalld's ...
  69. [69]
    Firewall - Ubuntu security documentation
    tools that work with nftables API and provide a compatible interface to the legacy implementation. The nftables backend has been the default since Ubuntu 20.10 ...
  70. [70]
    iptables-nftables-compat — Debian testing
    Jan 11, 2017 · The compat tools set allows you to manage the nf_tables backend using the native syntax of iptables(8), ip6tables(8), arptables(8), and ebtables ...
  71. [71]
    iptables vs nftables in Linux: What is The Difference? - TuxCare
    Feb 15, 2024 · In contrast, nftables, introduced with Linux kernel 3.13 in 2014, was designed to address some of the limitations seen in iptables. When ...
  72. [72]
    eBPF: When (and when not) to use it | Tigera
    Aug 24, 2021 · As you can see, comparing eBPF to iptables is not a straight apples-to-apples comparison. What we need to assess is performance, and the two ...
  73. [73]
    [PDF] Linux ACL Performance Analysis
    The analysis aimed to understand Linux ACL performance, finding eBPF has better throughput than IPSet and IPTables. Performance impacts cost, and metrics like ...
  74. [74]
    [PDF] eBPF / XDP based firewall and packet filtering
    From a performance point of view, we see huge wins for packet streams which hit the default deny rule when compared to iptables based firewalling. With the XDP ...
  75. [75]
    UFW Essentials: Common Firewall Rules and Commands for Linux ...
    Jul 31, 2025 · UFW is a command-line tool simplifying firewall management on Linux, built on iptables, and allows defining rules for network traffic.
  76. [76]
    UFW vs FirewallD - Ctrl.blog
    Feb 9, 2016 · UFW is simpler with easier syntax, while FirewallD has zone management and is better for roaming users. UFW is less intimidating for new users.
  77. [77]
    iptables vs. firewalld: Choosing your Linux firewall solution
    Nov 23, 2023 · This article compares iptables and firewalld, two key firewall management tools in Linux. Understand their unique features, ease of use, and management ...
  78. [78]
    Chapter 33. Firewalls | FreeBSD Documentation Portal
    33.3.​​ On FreeBSD, ALTQ can be used with PF to provide Quality of Service (QOS). Once ALTQ is enabled, queues can be defined in the ruleset which determine the ...
  79. [79]
    OpenBSD pf vs Linux iptables: A Comparison - worrbase
    Nov 14, 2009 · iptables has various tables, each with different chains that packets traverse, whereas pf just processes packets straight down the config file.
  80. [80]
    Configure Firewall Rules With Group Policy - Microsoft Learn
    Apr 7, 2025 · This article contains examples how to configure Windows Firewall rules using the Windows Firewall with Advanced Security console.