请输入您要查询的百科知识:

 

词条 Iptables
释义

  1. Overview

  2. Userspace utilities

     Front-ends  Other notable tools 

  3. See also

  4. References

  5. Literature

  6. External links

{{More footnotes|date=April 2015}}{{Lowercase title}}{{Infobox software
| name = iptables
| logo =
| screenshot =
| caption =
| author = Rusty Russell
| developer = Netfilter Core Team
| released = 1998
| programming language = C
| genre = Packet filtering
| license = GPL
| website = {{URL|http://www.netfilter.org/}}
| latest_release_version = 1.8.2
| latest_release_date = {{release date and age|2018|11|13}}[1]
| operating_system = Linux
}}

iptables is a user-space utility program that allows a system administrator to configure the tables[2] provided by the Linux kernel firewall (implemented as different Netfilter modules) and the chains and rules it stores. Different kernel modules and programs are currently used for different protocols; iptables applies to IPv4, ip6tables to IPv6, arptables to ARP, and ebtables to Ethernet frames.

iptables requires elevated privileges to operate and must be executed by user root, otherwise it fails to function. On most Linux systems, iptables is installed as /usr/sbin/iptables and documented in its man pages, which can be opened using man iptables when installed. It may also be found in /sbin/iptables, but since iptables is more like a service rather than an "essential binary", the preferred location remains /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.

The successor of iptables is nftables, which was merged into the Linux kernel mainline in kernel version 3.13, was released on 19 January 2014.[3]

Overview

Xtables allows the system administrator to define tables containing chains of rules for the treatment of packets. Each table is associated with a 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.

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.

  • PREROUTING: Packets will enter this chain before a routing decision is made.
  • INPUT: 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: ip route show table local.
  • FORWARD: All packets that have been routed and were not for local delivery will traverse this chain.
  • OUTPUT: Packets sent from the machine itself will be visiting this chain.
  • POSTROUTING: Routing decision has been made. Packets enter this chain just before handing them off to the hardware.

A chain does not exist by itself. A chain belongs to a table. There are three tables named: nat, filter, mangle. Unless precised by the option -t an iptables command concerns the filter table by default. For example the command iptables -L -v -n which shows some chains and their rules is equivalent to iptables -t filter -L -v -n. In order to show chains of table nat use the command: iptables -t nat -L -v -n

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 it 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 OSI model, as with e.g. the --mac-source and -p tcp --dport parameters, and there are also protocol-independent matches, such as -m time.

The packet continues to traverse the chain until either

  1. a rule matches the packet and decides the ultimate fate of the packet, for example by calling one of the ACCEPT or DROP, or a module returning such an ultimate fate; or
  2. a rule calls the RETURN verdict, in which case processing returns to the calling chain; or
  3. the end of the chain is reached; traversal either continues in the parent chain (as if RETURN was used), or the base chain policy, which is an ultimate fate, is used.

Targets also return a verdict like ACCEPT (NAT modules will do this) or DROP (e.g. the REJECT module), but may also imply CONTINUE (e.g. the LOG module; CONTINUE 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 textual or graphical fashion allow users to click-generate simple rulesets; scripts usually refer to shell scripts (but other scripting languages are possible too) that call iptables or (the faster) iptables-restore 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}}
  • NPF (firewall)
  • PF (firewall)
  • ipfirewall (ipfw)
  • ipfilter

References

1. ^{{Cite web | url = https://git.netfilter.org/iptables/tag/?h=v1.8.2 | title = iptables - iptables tree | date = 2018-11-13 | accessdate = 2018-11-17 | website = netfilter.org | first = Florian | last = Westphal}}
2. ^{{cite web|last1=Ayuso|first1=Pablo Neira|title=The netfilter.org "iptables" project|url=https://www.netfilter.org/projects/iptables/index.html|website=netfilter.org|accessdate=11 January 2017|deadurl=yes|archiveurl=https://web.archive.org/web/20170129062919/http://www.netfilter.org/projects/iptables/index.html|archivedate=29 January 2017|df=}}
3. ^{{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 | accessdate = 2014-01-20 | website = kernelnewbies.org}}

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}}
  • The netfilter/iptables project Web page
  • {{Freshmeat|iptables|iptables}}
  • The netfilter/iptables documentation page (outdated){{Clarify|date=November 2009}}
  • Detecting and deceiving network scans{{snd}} countermeasures against nmap
  • The IPTables ManPage for syntax help
  • [https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html Iptables Tutorial 1.2.2 by Oskar Andreasson]
  • [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}}

5 : Command-line software|Firewall software|Linux security software|Linux kernel features|Linux-only software

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/16 3:57:48