Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Iptables
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Linux firewall software}} {{Use dmy dates|date=January 2021}} {{More footnotes|date=April 2015}} {{Lowercase title}} {{Infobox software | name = iptables | logo = | screenshot = Iptablesfb.png | screenshot alt = Screenshot of "iptables -vnL" in framebuffer | screenshot title = Screenshot of "iptables -vnL" in framebuffer | caption = | author = [[Rusty Russell]] | developer = Netfilter Core Team | released = 2001 | programming language = [[C (programming language)|C]] | genre = [[Network packet|Packet filtering]] | license = [[GPL]] | website = {{URL|https://www.netfilter.org}} | latest_release_version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}} | latest_release_date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}}} | operating_system = [[Linux]] | platform = [[Netfilter]] }} '''iptables''' is a [[User space|user-space]] utility program that allows a [[system administrator]] to configure the [[Packet filter|IP packet filter rules]] of the [[Linux kernel]] [[Firewall (computing)|firewall]], implemented as different [[Netfilter]] modules. The filters are organized in a set of tables, which contain chains of rules for how to treat network traffic packets. Different kernel modules and programs are currently used for different protocols; ''iptables'' applies to IPv4, ''ip6tables'' to IPv6, ''arptables'' to [[Address Resolution Protocol|ARP]], and ''{{Not a typo|ebtables}}'' to [[Ethernet frame]]s. iptables requires elevated privileges to operate and must be executed by user [[Superuser|root]], otherwise it fails to function. On most Linux systems, iptables is installed as {{mono|/usr/sbin/iptables}} and documented in its [[man page]]s, which can be opened using <code>man iptables</code> when installed. It may also be found in <code>/sbin/iptables</code>, but since iptables is more like a service rather than an "essential binary", the preferred location remains {{mono|/usr/sbin}}. The term ''iptables'' is also commonly used to inclusively refer to the kernel-level components. ''x_tables'' is the name of the kernel module carrying the shared code portion used by all four modules that also provides the API used for extensions; subsequently, ''Xtables'' is more or less used to refer to the entire firewall (v4, v6, arp, and eb) architecture. iptables superseded [[ipchains]]; and the successor of iptables is [[nftables]], which was released on 19 January 2014<ref>{{cite web | title = Linux 3.13, Section 1.2. nftables, the successor of iptables | url = http://kernelnewbies.org/Linux_3.13#head-f628a9c41d7ec091f7a62db6a49b8da50659ec88 | date = 2014-01-19 | access-date = 2014-01-20 | website = kernelnewbies.org}}</ref> and was merged into the [[Linux kernel mainline]] in kernel version 3.13. ==Overview== iptables allows the [[system administrator]] to define ''tables'' containing ''chains'' of ''rules'' for the treatment of packets. Each table is associated with a [[Netfilter#iptables|different kind of packet processing]]. Packets are processed by sequentially traversing the rules in chains. A rule in a chain can cause a goto or jump to another chain, and this can be repeated to whatever level of nesting is desired. (A jump is like a βcallβ, i.e. the point that was jumped from is remembered.) Every network packet arriving at or leaving from the computer traverses at least one chain. [[Image:Netfilter-packet-flow.svg|350px|thumb|Packet flow paths. Packets start at a given box and will flow along a certain path, depending on the circumstances.]] The origin of the packet determines which chain it traverses initially. There are five ''predefined chains'' (mapping to the five available Netfilter hooks), though a table may not have all chains. Predefined chains have a ''policy'', for example DROP, which is applied to the packet if it reaches the end of the chain. The system administrator can create as many other chains as desired. These chains have no policy; if a packet reaches the end of the chain it is returned to the chain which called it. A chain may be empty. * <code>PREROUTING</code>: Packets will enter this chain before a routing decision is made. * <code>INPUT</code>: Packet is going to be locally delivered. It does not have anything to do with processes having an opened socket; local delivery is controlled by the "local-delivery" routing table: <code>ip route show table local</code>. * <code>FORWARD</code>: All packets that have been routed and were not for local delivery will traverse this chain. * <code>OUTPUT</code>: Packets sent from the machine itself will be visiting this chain. * <code>POSTROUTING</code>: Routing decision has been made. Packets enter this chain just before handing them off to the hardware. A chain does not exist by itself; it belongs to a ''table''. There are three tables: ''nat'', ''filter'', and ''mangle''. Unless preceded by the option ''-t'', an <code>iptables</code> command concerns the ''filter'' table by default. For example, the command <code>iptables -L -v -n</code>, which shows some chains and their rules, is equivalent to <code>iptables -t filter -L -v -n</code>. To show chains of table ''nat'', use the command <code>iptables -t nat -L -v -n</code> Each rule in a chain contains the specification of which packets it matches. It may also contain a ''target'' (used for extensions) or ''verdict'' (one of the built-in decisions). As a packet traverses a chain, each rule in turn is examined. If a rule does not match the packet, the packet is passed to the next rule. If a rule does match the packet, the rule takes the action indicated by the target/verdict, which may result in the packet being allowed to continue along the chain or may not. Matches make up the large part of rulesets, as they contain the conditions packets are tested for. These can happen for about any layer in the [[w:OSI_model|OSI]] model, as with e.g. the <code>--mac-source</code> and <code>-p tcp --dport</code> parameters, and there are also protocol-independent matches, such as <code>-m time</code>. The packet continues to traverse the chain until either # a rule matches the packet and decides the ultimate fate of the packet, for example by calling one of the <code>ACCEPT</code> or <code>DROP</code>, or a module returning such an ultimate fate; or # a rule calls the <code>RETURN</code> verdict, in which case processing returns to the calling chain; or # the end of the chain is reached; traversal either continues in the parent chain (as if <code>RETURN</code> was used), or the base chain policy, which is an ultimate fate, is used. Targets also return a verdict like <code>ACCEPT</code> (<code>NAT</code> modules will do this) or <code>DROP</code> (e.g. the <code>REJECT</code> module), but may also imply <code>CONTINUE</code> (e.g. the <code>LOG</code> module; <code>CONTINUE</code> is an internal name) to continue with the next rule as if no target/verdict was specified at all. ==Userspace utilities== ===Front-ends=== There are numerous third-party software applications for iptables that try to facilitate setting up rules. Front-ends in [[ncurses|textual]] or graphical fashion allow users to click-generate simple rulesets; scripts usually refer to [[Unix shell|shell scripts]] (but other scripting languages are possible too) that call iptables or (the faster) <code>iptables-restore</code> with a set of predefined rules, or rules expanded from a template with the help of a simple configuration file. Linux distributions commonly employ the latter scheme of using templates. Such a template-based approach is practically a limited form of a rule generator, and such generators also exist in standalone fashion, for example, as PHP web pages. Such front-ends, generators and scripts are often limited by their built-in template systems and where the templates offer substitution spots for user-defined rules. Also, the generated rules are generally not optimized for the particular firewalling effect the user wishes, as doing so will likely increase the maintenance cost for the developer. Users who reasonably understand iptables and want their ruleset optimized are advised to construct their own ruleset. ===Other notable tools=== * [[FireHOL]] β a shell script wrapping iptables with an easy-to-understand plain-text configuration file * [[NuFW]] β an authenticating firewall extension to Netfilter * [[Shorewall]] β a gateway/firewall configuration tool, making it possible to use easier rules and have them mapped to iptables ==See also== {{Portal|Free and open-source software|Linux}} * [[nftables]] * [[NPF (firewall)]] * [[PF (firewall)]] * [[ipfirewall]] (ipfw) * [[ipfilter]] * [[Express Data Path|XDP]] * [[ipchains]] * [[Uncomplicated Firewall]] (firewall) ==References== {{Reflist}} ==Literature== * {{cite book | author = Gregor N. Purdy | title = Linux iptables Pocket Reference: Firewalls, NAT & Accounting | url = https://books.google.com/books?id=CCk6xpGeYjwC | date = 25 August 2004 | publisher = O'Reilly Media, Inc. | isbn = 978-1-4493-7898-1}} ==External links== {{Sister project links |commons=no |b=Communication Networks/IP Tables |wikt=no |v=no |q=no |s=no}} * [http://www.netfilter.org/ The netfilter/iptables project Web page] * {{Freshmeat|iptables|iptables}} * [http://www.netfilter.org/documentation/index.html The netfilter/iptables documentation page] (outdated){{Clarify|date=November 2009}} * [http://inai.de/documents/Chaostables.pdf Detecting and deceiving network scans]{{snd}} countermeasures against nmap * [http://ipset.netfilter.org/iptables.man.html The IPTables ManPage for syntax help] * [https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html Iptables Tutorial 1.2.2 by Oskar Andreasson] * [http://www.linux-india.org/linux-firewall/ IPTABLES: The Default Linux Firewall] * [https://www.researchgate.net/profile/Mahmood_Ahmadi/publication/261550748_Acceleration_of_IPTABLES_Linux_Packet_Filtering_using_GPGPU/links/0c96053494b348cf52000000 Acceleration of iptables Linux Packet Filtering using GPGPU] {{-}} {{Firewall software}} {{Authority control}} [[Category:Command-line software]] [[Category:Firewall software]] [[Category:Linux security software]] [[Category:Linux kernel features]] [[Category:Linux-only free software]] [[Category:Free software programmed in C]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:-
(
edit
)
Template:Authority control
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Clarify
(
edit
)
Template:Clear
(
edit
)
Template:Firewall software
(
edit
)
Template:Freshmeat
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase title
(
edit
)
Template:Main other
(
edit
)
Template:Mono
(
edit
)
Template:More footnotes
(
edit
)
Template:Not a typo
(
edit
)
Template:Portal
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project links
(
edit
)
Template:Snd
(
edit
)
Template:Template other
(
edit
)
Template:Use dmy dates
(
edit
)