blob: 110c5994d7d5080a33293d6a848793be450da4cf [file] [log] [blame]
Jan Engelhardt8d671902009-01-08 18:03:45 +01001.TH IPTABLES 8 "" "@PACKAGE_AND_VERSION@" "@PACKAGE_AND_VERSION@"
Henrik Nordstromc2794132004-01-22 15:04:24 +00002.\"
3.\" Man page written by Herve Eychenne <rv@wallfire.org> (May 1999)
4.\" It is based on ipchains page.
5.\" TODO: add a word for protocol helpers (FTP, IRC, SNMP-ALG)
6.\"
7.\" ipchains page by Paul ``Rusty'' Russell March 1997
8.\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl>
9.\"
10.\" This program is free software; you can redistribute it and/or modify
11.\" it under the terms of the GNU General Public License as published by
12.\" the Free Software Foundation; either version 2 of the License, or
13.\" (at your option) any later version.
14.\"
15.\" This program is distributed in the hope that it will be useful,
16.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18.\" GNU General Public License for more details.
19.\"
20.\" You should have received a copy of the GNU General Public License
21.\" along with this program; if not, write to the Free Software
22.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23.\"
24.\"
25.SH NAME
Jan Engelhardt352ccfb2009-08-20 17:15:22 +020026iptables \(em administration tool for IPv4 packet filtering and NAT
Henrik Nordstromc2794132004-01-22 15:04:24 +000027.SH SYNOPSIS
Stefan Tomanekd59b9db2011-03-08 22:42:51 +010028\fBiptables\fP [\fB\-t\fP \fItable\fP] {\fB\-A\fP|\fB\-C\fP|\fB\-D\fP}
29\fIchain\fP \fIrule-specification\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010030.PP
Jan Engelhardt1791a452009-02-20 16:39:54 +010031\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-I\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010032.PP
Jan Engelhardt1791a452009-02-20 16:39:54 +010033\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-R\fP \fIchain rulenum rule-specification\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010034.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010035\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-D\fP \fIchain rulenum\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010036.PP
Jan Engelhardt1791a452009-02-20 16:39:54 +010037\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-S\fP [\fIchain\fP [\fIrulenum\fP]]
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010038.PP
Jan Engelhardtfe086ba2009-08-19 22:36:03 +020039\fBiptables\fP [\fB\-t\fP \fItable\fP] {\fB\-F\fP|\fB\-L\fP|\fB\-Z\fP} [\fIchain\fP [\fIrulenum\fP]] [\fIoptions...\fP]
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010040.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010041\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-N\fP \fIchain\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010042.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010043\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-X\fP [\fIchain\fP]
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010044.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010045\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-P\fP \fIchain target\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010046.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010047\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-E\fP \fIold-chain-name new-chain-name\fP
Jan Engelhardt6362bc82008-10-29 09:48:59 +010048.PP
49rule-specification = [\fImatches...\fP] [\fItarget\fP]
50.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010051match = \fB\-m\fP \fImatchname\fP [\fIper-match-options\fP]
Jan Engelhardt6362bc82008-10-29 09:48:59 +010052.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010053target = \fB\-j\fP \fItargetname\fP [\fIper\-target\-options\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +000054.SH DESCRIPTION
Jan Engelhardt55dffef2008-07-03 20:27:50 +020055\fBIptables\fP is used to set up, maintain, and inspect the
56tables of IPv4 packet
Henrik Nordstromc2794132004-01-22 15:04:24 +000057filter rules in the Linux kernel. Several different tables
58may be defined. Each table contains a number of built-in
59chains and may also contain user-defined chains.
Jan Engelhardt0c2b5a42009-01-08 18:04:40 +010060.PP
Henrik Nordstromc2794132004-01-22 15:04:24 +000061Each chain is a list of rules which can match a set of packets. Each
62rule specifies what to do with a packet that matches. This is called
63a `target', which may be a jump to a user-defined chain in the same
64table.
Henrik Nordstromc2794132004-01-22 15:04:24 +000065.SH TARGETS
Jan Engelhardt6cf172e2008-03-10 17:48:59 +010066A firewall rule specifies criteria for a packet and a target. If the
Henrik Nordstromc2794132004-01-22 15:04:24 +000067packet does not match, the next rule in the chain is the examined; if
68it does match, then the next rule is specified by the value of the
69target, which can be the name of a user-defined chain or one of the
Jan Engelhardt55dffef2008-07-03 20:27:50 +020070special values \fBACCEPT\fP, \fBDROP\fP, \fBQUEUE\fP or \fBRETURN\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +000071.PP
Jan Engelhardt55dffef2008-07-03 20:27:50 +020072\fBACCEPT\fP means to let the packet through.
73\fBDROP\fP means to drop the packet on the floor.
74\fBQUEUE\fP means to pass the packet to userspace.
75(How the packet can be received
Harald Welte7bdfca42005-07-28 15:24:02 +000076by a userspace process differs by the particular queue handler. 2.4.x
Jan Engelhardt55dffef2008-07-03 20:27:50 +020077and 2.6.x kernels up to 2.6.13 include the \fBip_queue\fP
78queue handler. Kernels 2.6.14 and later additionally include the
79\fBnfnetlink_queue\fP queue handler. Packets with a target of QUEUE will be
80sent to queue number '0' in this case. Please also see the \fBNFQUEUE\fP
Harald Welte7bdfca42005-07-28 15:24:02 +000081target as described later in this man page.)
Jan Engelhardt55dffef2008-07-03 20:27:50 +020082\fBRETURN\fP means stop traversing this chain and resume at the next
83rule in the
Henrik Nordstromc2794132004-01-22 15:04:24 +000084previous (calling) chain. If the end of a built-in chain is reached
Jan Engelhardt55dffef2008-07-03 20:27:50 +020085or a rule in a built-in chain with target \fBRETURN\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000086is matched, the target specified by the chain policy determines the
87fate of the packet.
88.SH TABLES
89There are currently three independent tables (which tables are present
90at any time depends on the kernel configuration options and which
91modules are present).
92.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010093\fB\-t\fP, \fB\-\-table\fP \fItable\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000094This option specifies the packet matching table which the command
95should operate on. If the kernel is configured with automatic module
96loading, an attempt will be made to load the appropriate module for
97that table if it is not already there.
98
99The tables are as follows:
100.RS
101.TP .4i
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200102\fBfilter\fP:
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100103This is the default table (if no \-t option is passed). It contains
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200104the built-in chains \fBINPUT\fP (for packets destined to local sockets),
105\fBFORWARD\fP (for packets being routed through the box), and
106\fBOUTPUT\fP (for locally-generated packets).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000107.TP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200108\fBnat\fP:
Henrik Nordstromc2794132004-01-22 15:04:24 +0000109This table is consulted when a packet that creates a new
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200110connection is encountered. It consists of three built-ins: \fBPREROUTING\fP
111(for altering packets as soon as they come in), \fBOUTPUT\fP
112(for altering locally-generated packets before routing), and \fBPOSTROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000113(for altering packets as they are about to go out).
114.TP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200115\fBmangle\fP:
Henrik Nordstromc2794132004-01-22 15:04:24 +0000116This table is used for specialized packet alteration. Until kernel
Jan Engelhardt55dffef2008-07-03 20:27:50 +02001172.4.17 it had two built-in chains: \fBPREROUTING\fP
118(for altering incoming packets before routing) and \fBOUTPUT\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000119(for altering locally-generated packets before routing).
120Since kernel 2.4.18, three other built-in chains are also supported:
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200121\fBINPUT\fP (for packets coming into the box itself), \fBFORWARD\fP
122(for altering packets being routed through the box), and \fBPOSTROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000123(for altering packets as they are about to go out).
Harald Weltea1885992004-10-06 12:32:54 +0000124.TP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200125\fBraw\fP:
Harald Weltea1885992004-10-06 12:32:54 +0000126This table is used mainly for configuring exemptions from connection
127tracking in combination with the NOTRACK target. It registers at the netfilter
128hooks with higher priority and is thus called before ip_conntrack, or any other
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200129IP tables. It provides the following built-in chains: \fBPREROUTING\fP
130(for packets arriving via any network interface) \fBOUTPUT\fP
Harald Weltea1885992004-10-06 12:32:54 +0000131(for packets generated by local processes)
Mark Montaguedf37d992011-04-04 14:54:52 +0200132.TP
133\fBsecurity\fP:
134This table is used for Mandatory Access Control (MAC) networking rules, such
135as those enabled by the \fBSECMARK\fP and \fBCONNSECMARK\fP targets.
136Mandatory Access Control is implemented by Linux Security Modules such as
137SELinux. The security table is called after the filter table, allowing any
138Discretionary Access Control (DAC) rules in the filter table to take effect
139before MAC rules. This table provides the following built-in chains:
140\fBINPUT\fP (for packets coming into the box itself),
141\fBOUTPUT\fP (for altering locally-generated packets before routing), and
142\fBFORWARD\fP (for altering packets being routed through the box).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000143.RE
144.SH OPTIONS
145The options that are recognized by
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200146\fBiptables\fP can be divided into several different groups.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000147.SS COMMANDS
Jan Engelhardt6cf172e2008-03-10 17:48:59 +0100148These options specify the desired action to perform. Only one of them
149can be specified on the command line unless otherwise stated
150below. For long versions of the command and option names, you
Henrik Nordstromc2794132004-01-22 15:04:24 +0000151need to use only enough letters to ensure that
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200152\fBiptables\fP can differentiate it from all other options.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000153.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100154\fB\-A\fP, \fB\-\-append\fP \fIchain rule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000155Append one or more rules to the end of the selected chain.
156When the source and/or destination names resolve to more than one
157address, a rule will be added for each possible address combination.
158.TP
Stefan Tomanekd59b9db2011-03-08 22:42:51 +0100159\fB\-C\fP, \fB\-\-check\fP \fIchain rule-specification\fP
160Check whether a rule matching the specification does exist in the
161selected chain. This command uses the same logic as \fB\-D\fP to
162find a matching entry, but does not alter the existing iptables
163configuration and uses its exit code to indicate success or failure.
164.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100165\fB\-D\fP, \fB\-\-delete\fP \fIchain rule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000166.ns
167.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100168\fB\-D\fP, \fB\-\-delete\fP \fIchain rulenum\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000169Delete one or more rules from the selected chain. There are two
170versions of this command: the rule can be specified as a number in the
171chain (starting at 1 for the first rule) or a rule to match.
172.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100173\fB\-I\fP, \fB\-\-insert\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000174Insert one or more rules in the selected chain as the given rule
175number. So, if the rule number is 1, the rule or rules are inserted
176at the head of the chain. This is also the default if no rule number
177is specified.
178.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100179\fB\-R\fP, \fB\-\-replace\fP \fIchain rulenum rule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000180Replace a rule in the selected chain. If the source and/or
181destination names resolve to multiple addresses, the command will
182fail. Rules are numbered starting at 1.
183.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100184\fB\-L\fP, \fB\-\-list\fP [\fIchain\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +0000185List all rules in the selected chain. If no chain is selected, all
Jan Engelhardt6cf172e2008-03-10 17:48:59 +0100186chains are listed. Like every other iptables command, it applies to the
Henrik Nordstromc2794132004-01-22 15:04:24 +0000187specified table (filter is the default), so NAT rules get listed by
188.nf
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100189 iptables \-t nat \-n \-L
Henrik Nordstromc2794132004-01-22 15:04:24 +0000190.fi
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100191Please note that it is often used with the \fB\-n\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000192option, in order to avoid long reverse DNS lookups.
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100193It is legal to specify the \fB\-Z\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000194(zero) option as well, in which case the chain(s) will be atomically
195listed and zeroed. The exact output is affected by the other
196arguments given. The exact rules are suppressed until you use
197.nf
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100198 iptables \-L \-v
Henrik Nordstromc2794132004-01-22 15:04:24 +0000199.fi
200.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100201\fB\-S\fP, \fB\-\-list\-rules\fP [\fIchain\fP]
Henrik Nordstrom96296cf2008-05-13 13:08:26 +0200202Print all rules in the selected chain. If no chain is selected, all
Jan Engelhardt352ccfb2009-08-20 17:15:22 +0200203chains are printed like iptables-save. Like every other iptables command,
Henrik Nordstrom96296cf2008-05-13 13:08:26 +0200204it applies to the specified table (filter is the default).
205.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100206\fB\-F\fP, \fB\-\-flush\fP [\fIchain\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +0000207Flush the selected chain (all the chains in the table if none is given).
208This is equivalent to deleting all the rules one by one.
209.TP
Jan Engelhardtfe086ba2009-08-19 22:36:03 +0200210\fB\-Z\fP, \fB\-\-zero\fP [\fIchain\fP [\fIrulenum\fP]]
211Zero the packet and byte counters in all chains, or only the given chain,
212or only the given rule in a chain. It is legal to
Henrik Nordstromc2794132004-01-22 15:04:24 +0000213specify the
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100214\fB\-L\fP, \fB\-\-list\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000215(list) option as well, to see the counters immediately before they are
216cleared. (See above.)
217.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100218\fB\-N\fP, \fB\-\-new\-chain\fP \fIchain\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000219Create a new user-defined chain by the given name. There must be no
220target of that name already.
221.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100222\fB\-X\fP, \fB\-\-delete\-chain\fP [\fIchain\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +0000223Delete the optional user-defined chain specified. There must be no references
Harald Welte3a026932005-11-22 22:22:28 +0000224to the chain. If there are, you must delete or replace the referring rules
225before the chain can be deleted. The chain must be empty, i.e. not contain
226any rules. If no argument is given, it will attempt to delete every
227non-builtin chain in the table.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000228.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100229\fB\-P\fP, \fB\-\-policy\fP \fIchain target\fP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200230Set the policy for the chain to the given target. See the section \fBTARGETS\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000231for the legal targets. Only built-in (non-user-defined) chains can have
232policies, and neither built-in nor user-defined chains can be policy
233targets.
234.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100235\fB\-E\fP, \fB\-\-rename\-chain\fP \fIold\-chain new\-chain\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000236Rename the user specified chain to the user supplied name. This is
237cosmetic, and has no effect on the structure of the table.
238.TP
Laurence J. Lanecfb048f2009-08-20 17:14:25 +0200239\fB\-h\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000240Help.
241Give a (currently very brief) description of the command syntax.
242.SS PARAMETERS
243The following parameters make up a rule specification (as used in the
244add, delete, insert, replace and append commands).
245.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100246[\fB!\fP] \fB\-p\fP, \fB\-\-protocol\fP \fIprotocol\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000247The protocol of the rule or of the packet to check.
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200248The specified protocol can be one of \fBtcp\fP, \fBudp\fP, \fBudplite\fP,
249\fBicmp\fP, \fBesp\fP, \fBah\fP, \fBsctp\fP or \fBall\fP,
Henrik Nordstromc2794132004-01-22 15:04:24 +0000250or it can be a numeric value, representing one of these protocols or a
251different one. A protocol name from /etc/protocols is also allowed.
252A "!" argument before the protocol inverts the
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200253test. The number zero is equivalent to \fBall\fP.
254Protocol \fBall\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000255will match with all protocols and is taken as default when this
256option is omitted.
257.TP
Michael Granzow332e4ac2009-04-09 18:24:36 +0100258[\fB!\fP] \fB\-s\fP, \fB\-\-source\fP \fIaddress\fP[\fB/\fP\fImask\fP][\fB,\fP\fI...\fP]
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200259Source specification. \fIAddress\fP
Jan Engelhardt1bd2f0a2009-11-18 00:00:37 +0100260can be either a network name, a hostname, a network IP address (with
261\fB/\fP\fImask\fP), or a plain IP address. Hostnames will
262be resolved once only, before the rule is submitted to the kernel.
263Please note that specifying any name to be resolved with a remote query such as
264DNS is a really bad idea.
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200265The \fImask\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000266can be either a network mask or a plain number,
267specifying the number of 1's at the left side of the network mask.
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200268Thus, a mask of \fI24\fP is equivalent to \fI255.255.255.0\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000269A "!" argument before the address specification inverts the sense of
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100270the address. The flag \fB\-\-src\fP is an alias for this option.
Michael Granzow332e4ac2009-04-09 18:24:36 +0100271Multiple addresses can be specified, but this will \fBexpand to multiple
272rules\fP (when adding with \-A), or will cause multiple rules to be
273deleted (with \-D).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000274.TP
Michael Granzow332e4ac2009-04-09 18:24:36 +0100275[\fB!\fP] \fB\-d\fP, \fB\-\-destination\fP \fIaddress\fP[\fB/\fP\fImask\fP][\fB,\fP\fI...\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +0000276Destination specification.
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100277See the description of the \fB\-s\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000278(source) flag for a detailed description of the syntax. The flag
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100279\fB\-\-dst\fP is an alias for this option.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000280.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100281\fB\-j\fP, \fB\-\-jump\fP \fItarget\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000282This specifies the target of the rule; i.e., what to do if the packet
283matches it. The target can be a user-defined chain (other than the
284one this rule is in), one of the special builtin targets which decide
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200285the fate of the packet immediately, or an extension (see \fBEXTENSIONS\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000286below). If this
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100287option is omitted in a rule (and \fB\-g\fP
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000288is not used), then matching the rule will have no
Henrik Nordstromc2794132004-01-22 15:04:24 +0000289effect on the packet's fate, but the counters on the rule will be
290incremented.
291.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100292\fB\-g\fP, \fB\-\-goto\fP \fIchain\fP
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000293This specifies that the processing should continue in a user
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100294specified chain. Unlike the \-\-jump option return will not continue
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000295processing in this chain but instead in the chain that called us via
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100296\-\-jump.
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000297.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100298[\fB!\fP] \fB\-i\fP, \fB\-\-in\-interface\fP \fIname\fP
Matthew Strait403cf6a2004-03-17 14:26:08 +0000299Name of an interface via which a packet was received (only for
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200300packets entering the \fBINPUT\fP, \fBFORWARD\fP and \fBPREROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000301chains). When the "!" argument is used before the interface name, the
302sense is inverted. If the interface name ends in a "+", then any
303interface which begins with this name will match. If this option is
304omitted, any interface name will match.
305.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100306[\fB!\fP] \fB\-o\fP, \fB\-\-out\-interface\fP \fIname\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000307Name of an interface via which a packet is going to be sent (for packets
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200308entering the \fBFORWARD\fP, \fBOUTPUT\fP and \fBPOSTROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000309chains). When the "!" argument is used before the interface name, the
310sense is inverted. If the interface name ends in a "+", then any
311interface which begins with this name will match. If this option is
312omitted, any interface name will match.
313.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100314[\fB!\fP] \fB\-f\fP, \fB\-\-fragment\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000315This means that the rule only refers to second and further fragments
316of fragmented packets. Since there is no way to tell the source or
317destination ports of such a packet (or ICMP type), such a packet will
318not match any rules which specify them. When the "!" argument
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100319precedes the "\-f" flag, the rule will only match head fragments, or
Henrik Nordstromc2794132004-01-22 15:04:24 +0000320unfragmented packets.
321.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100322\fB\-c\fP, \fB\-\-set\-counters\fP \fIpackets bytes\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000323This enables the administrator to initialize the packet and byte
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200324counters of a rule (during \fBINSERT\fP, \fBAPPEND\fP, \fBREPLACE\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000325operations).
326.SS "OTHER OPTIONS"
327The following additional options can be specified:
328.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100329\fB\-v\fP, \fB\-\-verbose\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000330Verbose output. This option makes the list command show the interface
331name, the rule options (if any), and the TOS masks. The packet and
332byte counters are also listed, with the suffix 'K', 'M' or 'G' for
3331000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100334the \fB\-x\fP flag to change this).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000335For appending, insertion, deletion and replacement, this causes
336detailed information on the rule or rules to be printed.
337.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100338\fB\-n\fP, \fB\-\-numeric\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000339Numeric output.
340IP addresses and port numbers will be printed in numeric format.
341By default, the program will try to display them as host names,
342network names, or services (whenever applicable).
343.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100344\fB\-x\fP, \fB\-\-exact\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000345Expand numbers.
346Display the exact value of the packet and byte counters,
347instead of only the rounded number in K's (multiples of 1000)
348M's (multiples of 1000K) or G's (multiples of 1000M). This option is
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100349only relevant for the \fB\-L\fP command.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000350.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100351\fB\-\-line\-numbers\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000352When listing rules, add line numbers to the beginning of each rule,
353corresponding to that rule's position in the chain.
354.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100355\fB\-\-modprobe=\fP\fIcommand\fP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200356When adding or inserting rules into a chain, use \fIcommand\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000357to load any necessary modules (targets, match extensions, etc).
358.SH MATCH EXTENSIONS
359iptables can use extended packet matching modules. These are loaded
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100360in two ways: implicitly, when \fB\-p\fP or \fB\-\-protocol\fP
361is specified, or with the \fB\-m\fP or \fB\-\-match\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000362options, followed by the matching module name; after these, various
363extra command line options become available, depending on the specific
364module. You can specify multiple extended match modules in one line,
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100365and you can use the \fB\-h\fP or \fB\-\-help\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000366options after the module has been specified to receive help specific
367to that module.
Jan Engelhardt0c2b5a42009-01-08 18:04:40 +0100368.PP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000369The following are included in the base package, and most of these can
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200370be preceded by a "\fB!\fP" to invert the sense of the match.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000371.\" @MATCH@
372.SH TARGET EXTENSIONS
373iptables can use extended target modules: the following are included
374in the standard distribution.
375.\" @TARGET@
376.SH DIAGNOSTICS
377Various error messages are printed to standard error. The exit code
378is 0 for correct functioning. Errors which appear to be caused by
379invalid or abused command line parameters cause an exit code of 2, and
380other errors cause an exit code of 1.
381.SH BUGS
382Bugs? What's this? ;-)
Harald Welte64d900f2005-06-24 16:37:00 +0000383Well, you might want to have a look at http://bugzilla.netfilter.org/
Henrik Nordstromc2794132004-01-22 15:04:24 +0000384.SH COMPATIBILITY WITH IPCHAINS
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200385This \fBiptables\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000386is very similar to ipchains by Rusty Russell. The main difference is
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200387that the chains \fBINPUT\fP and \fBOUTPUT\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000388are only traversed for packets coming into the local host and
389originating from the local host respectively. Hence every packet only
390passes through one of the three chains (except loopback traffic, which
391involves both INPUT and OUTPUT chains); previously a forwarded packet
392would pass through all three.
393.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100394The other main difference is that \fB\-i\fP refers to the input interface;
395\fB\-o\fP refers to the output interface, and both are available for packets
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200396entering the \fBFORWARD\fP chain.
397.PP
398The various forms of NAT have been separated out; \fBiptables\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000399is a pure packet filter when using the default `filter' table, with
400optional extension modules. This should simplify much of the previous
401confusion over the combination of IP masquerading and packet filtering
402seen previously. So the following options are handled differently:
403.nf
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100404 \-j MASQ
405 \-M \-S
406 \-M \-L
Henrik Nordstromc2794132004-01-22 15:04:24 +0000407.fi
408There are several other changes in iptables.
409.SH SEE ALSO
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100410\fBiptables\-save\fP(8),
411\fBiptables\-restore\fP(8),
412\fBip6tables\fP(8),
413\fBip6tables\-save\fP(8),
414\fBip6tables\-restore\fP(8),
415\fBlibipq\fP(3).
416.PP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000417The packet-filtering-HOWTO details iptables usage for
418packet filtering, the NAT-HOWTO details NAT,
419the netfilter-extensions-HOWTO details the extensions that are
420not in the standard distribution,
421and the netfilter-hacking-HOWTO details the netfilter internals.
422.br
423See
424.BR "http://www.netfilter.org/" .
425.SH AUTHORS
Harald Welte7bdfca42005-07-28 15:24:02 +0000426Rusty Russell originally wrote iptables, in early consultation with Michael
Henrik Nordstromc2794132004-01-22 15:04:24 +0000427Neuling.
428.PP
429Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
430selection framework in iptables, then wrote the mangle table, the owner match,
431the mark stuff, and ran around doing cool stuff everywhere.
432.PP
433James Morris wrote the TOS target, and tos match.
434.PP
435Jozsef Kadlecsik wrote the REJECT target.
436.PP
Harald Welte7bdfca42005-07-28 15:24:02 +0000437Harald Welte wrote the ULOG and NFQUEUE target, the new libiptc, as well as the TTL, DSCP, ECN matches and targets.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000438.PP
Patrick McHardy110a89a2007-01-28 01:24:55 +0000439The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Yasuyuki Kozakai,
Yasuyuki KOZAKAIe605d762007-02-15 06:41:58 +0000440Jozsef Kadlecsik, Patrick McHardy, James Morris, Pablo Neira Ayuso,
441Harald Welte and Rusty Russell.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000442.PP
Harald Welte7bdfca42005-07-28 15:24:02 +0000443Man page originally written by Herve Eychenne <rv@wallfire.org>.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000444.\" .. and did I mention that we are incredibly cool people?
445.\" .. sexy, too ..
446.\" .. witty, charming, powerful ..
447.\" .. and most of all, modest ..
Jan Engelhardtf96cb802011-03-01 12:51:21 +0100448.SH VERSION
449.PP
450This manual page applies to iptables @PACKAGE_VERSION@.