blob: a9c6b2521a77dc098fbc79fe20a5068719707566 [file] [log] [blame]
Andy Spencer14bca552013-05-19 17:01:06 +00001.TH IPTABLES 8 "" "@PACKAGE_STRING@" "@PACKAGE_STRING@"
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
Florian Westphalc25defa2013-07-14 19:32:12 +020026iptables/ip6tables \(em administration tool for IPv4/IPv6 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
Florian Westphalc25defa2013-07-14 19:32:12 +020030.P
31\fBip6tables\fP [\fB\-t\fP \fItable\fP] {\fB\-A\fP|\fB\-C\fP|\fB\-D\fP}
32\fIchain rule-specification\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010033.PP
Jan Engelhardt1791a452009-02-20 16:39:54 +010034\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-I\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010035.PP
Jan Engelhardt1791a452009-02-20 16:39:54 +010036\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-R\fP \fIchain rulenum rule-specification\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010037.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010038\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-D\fP \fIchain rulenum\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010039.PP
Jan Engelhardt1791a452009-02-20 16:39:54 +010040\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-S\fP [\fIchain\fP [\fIrulenum\fP]]
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010041.PP
Jan Engelhardtfe086ba2009-08-19 22:36:03 +020042\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 +010043.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010044\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-N\fP \fIchain\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010045.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010046\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-X\fP [\fIchain\fP]
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010047.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010048\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-P\fP \fIchain target\fP
Jan Engelhardt8a679dc2008-10-29 09:48:23 +010049.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010050\fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-E\fP \fIold-chain-name new-chain-name\fP
Jan Engelhardt6362bc82008-10-29 09:48:59 +010051.PP
52rule-specification = [\fImatches...\fP] [\fItarget\fP]
53.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010054match = \fB\-m\fP \fImatchname\fP [\fIper-match-options\fP]
Jan Engelhardt6362bc82008-10-29 09:48:59 +010055.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010056target = \fB\-j\fP \fItargetname\fP [\fIper\-target\-options\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +000057.SH DESCRIPTION
Florian Westphalc25defa2013-07-14 19:32:12 +020058\fBIptables\fP and \fBip6tables\fP are used to set up, maintain, and inspect the
59tables of IPv4 and IPv6 packet
Henrik Nordstromc2794132004-01-22 15:04:24 +000060filter rules in the Linux kernel. Several different tables
61may be defined. Each table contains a number of built-in
62chains and may also contain user-defined chains.
Jan Engelhardt0c2b5a42009-01-08 18:04:40 +010063.PP
Henrik Nordstromc2794132004-01-22 15:04:24 +000064Each chain is a list of rules which can match a set of packets. Each
65rule specifies what to do with a packet that matches. This is called
66a `target', which may be a jump to a user-defined chain in the same
67table.
Henrik Nordstromc2794132004-01-22 15:04:24 +000068.SH TARGETS
Jan Engelhardt6cf172e2008-03-10 17:48:59 +010069A firewall rule specifies criteria for a packet and a target. If the
Florian Westphal54fccb12013-07-12 23:14:27 +020070packet does not match, the next rule in the chain is examined; if
Henrik Nordstromc2794132004-01-22 15:04:24 +000071it does match, then the next rule is specified by the value of the
Florian Westphal54fccb12013-07-12 23:14:27 +020072target, which can be the name of a user-defined chain, one of the targets
73described in \fBiptables\-extensions\fP(8), or one of the
74special values \fBACCEPT\fP, \fBDROP\fP or \fBRETURN\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +000075.PP
Jan Engelhardt55dffef2008-07-03 20:27:50 +020076\fBACCEPT\fP means to let the packet through.
77\fBDROP\fP means to drop the packet on the floor.
Jan Engelhardt55dffef2008-07-03 20:27:50 +020078\fBRETURN\fP means stop traversing this chain and resume at the next
79rule in the
Henrik Nordstromc2794132004-01-22 15:04:24 +000080previous (calling) chain. If the end of a built-in chain is reached
Jan Engelhardt55dffef2008-07-03 20:27:50 +020081or a rule in a built-in chain with target \fBRETURN\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000082is matched, the target specified by the chain policy determines the
83fate of the packet.
84.SH TABLES
Pablo Neira Ayusoe422fd22013-02-17 14:05:35 +010085There are currently five independent tables (which tables are present
Henrik Nordstromc2794132004-01-22 15:04:24 +000086at any time depends on the kernel configuration options and which
87modules are present).
88.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010089\fB\-t\fP, \fB\-\-table\fP \fItable\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000090This option specifies the packet matching table which the command
91should operate on. If the kernel is configured with automatic module
92loading, an attempt will be made to load the appropriate module for
93that table if it is not already there.
94
95The tables are as follows:
96.RS
97.TP .4i
Jan Engelhardt55dffef2008-07-03 20:27:50 +020098\fBfilter\fP:
Jan Engelhardt0e8984a2009-01-12 07:06:12 +010099This is the default table (if no \-t option is passed). It contains
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200100the built-in chains \fBINPUT\fP (for packets destined to local sockets),
101\fBFORWARD\fP (for packets being routed through the box), and
102\fBOUTPUT\fP (for locally-generated packets).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000103.TP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200104\fBnat\fP:
Henrik Nordstromc2794132004-01-22 15:04:24 +0000105This table is consulted when a packet that creates a new
Florian Westphald7b813f2016-04-26 18:15:43 +0200106connection is encountered. It consists of four built-ins: \fBPREROUTING\fP
107(for altering packets as soon as they come in), \fBINPUT\fP (for altering
108packets destined for local sockets), \fBOUTPUT\fP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200109(for altering locally-generated packets before routing), and \fBPOSTROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000110(for altering packets as they are about to go out).
Florian Westphalc25defa2013-07-14 19:32:12 +0200111IPv6 NAT support is available since kernel 3.7.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000112.TP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200113\fBmangle\fP:
Henrik Nordstromc2794132004-01-22 15:04:24 +0000114This table is used for specialized packet alteration. Until kernel
Jan Engelhardt55dffef2008-07-03 20:27:50 +02001152.4.17 it had two built-in chains: \fBPREROUTING\fP
116(for altering incoming packets before routing) and \fBOUTPUT\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000117(for altering locally-generated packets before routing).
118Since kernel 2.4.18, three other built-in chains are also supported:
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200119\fBINPUT\fP (for packets coming into the box itself), \fBFORWARD\fP
120(for altering packets being routed through the box), and \fBPOSTROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000121(for altering packets as they are about to go out).
Harald Weltea1885992004-10-06 12:32:54 +0000122.TP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200123\fBraw\fP:
Harald Weltea1885992004-10-06 12:32:54 +0000124This table is used mainly for configuring exemptions from connection
125tracking in combination with the NOTRACK target. It registers at the netfilter
126hooks with higher priority and is thus called before ip_conntrack, or any other
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200127IP tables. It provides the following built-in chains: \fBPREROUTING\fP
128(for packets arriving via any network interface) \fBOUTPUT\fP
Harald Weltea1885992004-10-06 12:32:54 +0000129(for packets generated by local processes)
Mark Montaguedf37d992011-04-04 14:54:52 +0200130.TP
131\fBsecurity\fP:
132This table is used for Mandatory Access Control (MAC) networking rules, such
133as those enabled by the \fBSECMARK\fP and \fBCONNSECMARK\fP targets.
134Mandatory Access Control is implemented by Linux Security Modules such as
135SELinux. The security table is called after the filter table, allowing any
136Discretionary Access Control (DAC) rules in the filter table to take effect
137before MAC rules. This table provides the following built-in chains:
138\fBINPUT\fP (for packets coming into the box itself),
139\fBOUTPUT\fP (for altering locally-generated packets before routing), and
140\fBFORWARD\fP (for altering packets being routed through the box).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000141.RE
142.SH OPTIONS
143The options that are recognized by
Florian Westphalc25defa2013-07-14 19:32:12 +0200144\fBiptables\fP and \fBip6tables\fP can be divided into several different groups.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000145.SS COMMANDS
Jan Engelhardt6cf172e2008-03-10 17:48:59 +0100146These options specify the desired action to perform. Only one of them
147can be specified on the command line unless otherwise stated
148below. For long versions of the command and option names, you
Henrik Nordstromc2794132004-01-22 15:04:24 +0000149need to use only enough letters to ensure that
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200150\fBiptables\fP can differentiate it from all other options.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000151.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100152\fB\-A\fP, \fB\-\-append\fP \fIchain rule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000153Append one or more rules to the end of the selected chain.
154When the source and/or destination names resolve to more than one
155address, a rule will be added for each possible address combination.
156.TP
Stefan Tomanekd59b9db2011-03-08 22:42:51 +0100157\fB\-C\fP, \fB\-\-check\fP \fIchain rule-specification\fP
158Check whether a rule matching the specification does exist in the
159selected chain. This command uses the same logic as \fB\-D\fP to
160find a matching entry, but does not alter the existing iptables
161configuration and uses its exit code to indicate success or failure.
162.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100163\fB\-D\fP, \fB\-\-delete\fP \fIchain rule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000164.ns
165.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100166\fB\-D\fP, \fB\-\-delete\fP \fIchain rulenum\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000167Delete one or more rules from the selected chain. There are two
168versions of this command: the rule can be specified as a number in the
169chain (starting at 1 for the first rule) or a rule to match.
170.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100171\fB\-I\fP, \fB\-\-insert\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000172Insert one or more rules in the selected chain as the given rule
173number. So, if the rule number is 1, the rule or rules are inserted
174at the head of the chain. This is also the default if no rule number
175is specified.
176.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100177\fB\-R\fP, \fB\-\-replace\fP \fIchain rulenum rule-specification\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000178Replace a rule in the selected chain. If the source and/or
179destination names resolve to multiple addresses, the command will
180fail. Rules are numbered starting at 1.
181.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100182\fB\-L\fP, \fB\-\-list\fP [\fIchain\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +0000183List all rules in the selected chain. If no chain is selected, all
Jan Engelhardt6cf172e2008-03-10 17:48:59 +0100184chains are listed. Like every other iptables command, it applies to the
Henrik Nordstromc2794132004-01-22 15:04:24 +0000185specified table (filter is the default), so NAT rules get listed by
186.nf
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100187 iptables \-t nat \-n \-L
Henrik Nordstromc2794132004-01-22 15:04:24 +0000188.fi
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100189Please note that it is often used with the \fB\-n\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000190option, in order to avoid long reverse DNS lookups.
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100191It is legal to specify the \fB\-Z\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000192(zero) option as well, in which case the chain(s) will be atomically
193listed and zeroed. The exact output is affected by the other
194arguments given. The exact rules are suppressed until you use
195.nf
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100196 iptables \-L \-v
Henrik Nordstromc2794132004-01-22 15:04:24 +0000197.fi
Florian Westphal7e120ef2016-01-05 00:29:10 +0100198or
199\fBiptables\-save\fP(8).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000200.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
Florian Westphal69f3f842014-04-17 13:03:00 +0200230Set the policy for the built-in (non-user-defined) chain to the given target.
231The policy target must be either \fBACCEPT\fP or \fBDROP\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000232.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100233\fB\-E\fP, \fB\-\-rename\-chain\fP \fIold\-chain new\-chain\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000234Rename the user specified chain to the user supplied name. This is
235cosmetic, and has no effect on the structure of the table.
236.TP
Laurence J. Lanecfb048f2009-08-20 17:14:25 +0200237\fB\-h\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000238Help.
239Give a (currently very brief) description of the command syntax.
240.SS PARAMETERS
241The following parameters make up a rule specification (as used in the
242add, delete, insert, replace and append commands).
243.TP
Jan Engelhardt983196c2012-12-25 13:11:28 +0000244\fB\-4\fP, \fB\-\-ipv4\fP
245This option has no effect in iptables and iptables-restore.
Florian Westphalc25defa2013-07-14 19:32:12 +0200246If a rule using the \fB\-4\fP option is inserted with (and only with)
247ip6tables-restore, it will be silently ignored. Any other uses will throw an
248error. This option allows to put both IPv4 and IPv6 rules in a single rule file
249for use with both iptables-restore and ip6tables-restore.
Jan Engelhardt983196c2012-12-25 13:11:28 +0000250.TP
251\fB\-6\fP, \fB\-\-ipv6\fP
252If a rule using the \fB\-6\fP option is inserted with (and only with)
253iptables-restore, it will be silently ignored. Any other uses will throw an
254error. This option allows to put both IPv4 and IPv6 rules in a single rule file
255for use with both iptables-restore and ip6tables-restore.
Florian Westphalc25defa2013-07-14 19:32:12 +0200256This option has no effect in ip6tables and ip6tables-restore.
Jan Engelhardt983196c2012-12-25 13:11:28 +0000257.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100258[\fB!\fP] \fB\-p\fP, \fB\-\-protocol\fP \fIprotocol\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000259The protocol of the rule or of the packet to check.
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200260The specified protocol can be one of \fBtcp\fP, \fBudp\fP, \fBudplite\fP,
Florian Westphalc25defa2013-07-14 19:32:12 +0200261\fBicmp\fP, \fBicmpv6\fP,\fBesp\fP, \fBah\fP, \fBsctp\fP, \fBmh\fP or the special keyword "\fBall\fP",
Henrik Nordstromc2794132004-01-22 15:04:24 +0000262or it can be a numeric value, representing one of these protocols or a
263different one. A protocol name from /etc/protocols is also allowed.
264A "!" argument before the protocol inverts the
Jan Engelhardt10345ca2011-05-21 00:58:44 +0200265test. The number zero is equivalent to \fBall\fP. "\fBall\fP"
Henrik Nordstromc2794132004-01-22 15:04:24 +0000266will match with all protocols and is taken as default when this
267option is omitted.
Florian Westphalc25defa2013-07-14 19:32:12 +0200268Note that, in ip6tables, IPv6 extension headers except \fBesp\fP are not allowed.
269\fBesp\fP and \fBipv6\-nonext\fP
270can be used with Kernel version 2.6.11 or later.
271The number zero is equivalent to \fBall\fP, which means that you cannot
272test the protocol field for the value 0 directly. To match on a HBH header,
273even if it were the last, you cannot use \fB\-p 0\fP, but always need
274\fB\-m hbh\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000275.TP
Michael Granzow332e4ac2009-04-09 18:24:36 +0100276[\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 +0200277Source specification. \fIAddress\fP
Jan Engelhardt1bd2f0a2009-11-18 00:00:37 +0100278can be either a network name, a hostname, a network IP address (with
279\fB/\fP\fImask\fP), or a plain IP address. Hostnames will
280be resolved once only, before the rule is submitted to the kernel.
281Please note that specifying any name to be resolved with a remote query such as
282DNS is a really bad idea.
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200283The \fImask\fP
Florian Westphalc25defa2013-07-14 19:32:12 +0200284can be either an ipv4 network mask (for iptables) or a plain number,
Henrik Nordstromc2794132004-01-22 15:04:24 +0000285specifying the number of 1's at the left side of the network mask.
Florian Westphalc25defa2013-07-14 19:32:12 +0200286Thus, an iptables mask of \fI24\fP is equivalent to \fI255.255.255.0\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000287A "!" argument before the address specification inverts the sense of
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100288the address. The flag \fB\-\-src\fP is an alias for this option.
Michael Granzow332e4ac2009-04-09 18:24:36 +0100289Multiple addresses can be specified, but this will \fBexpand to multiple
290rules\fP (when adding with \-A), or will cause multiple rules to be
291deleted (with \-D).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000292.TP
Michael Granzow332e4ac2009-04-09 18:24:36 +0100293[\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 +0000294Destination specification.
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100295See the description of the \fB\-s\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000296(source) flag for a detailed description of the syntax. The flag
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100297\fB\-\-dst\fP is an alias for this option.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000298.TP
Jan Engelhardtdb1414e2012-12-25 13:11:27 +0000299\fB\-m\fP, \fB\-\-match\fP \fImatch\fP
300Specifies a match to use, that is, an extension module that tests for a
301specific property. The set of matches make up the condition under which a
302target is invoked. Matches are evaluated first to last as specified on the
303command line and work in short-circuit fashion, i.e. if one extension yields
304false, evaluation will stop.
305.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100306\fB\-j\fP, \fB\-\-jump\fP \fItarget\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000307This specifies the target of the rule; i.e., what to do if the packet
308matches it. The target can be a user-defined chain (other than the
309one this rule is in), one of the special builtin targets which decide
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200310the fate of the packet immediately, or an extension (see \fBEXTENSIONS\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000311below). If this
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100312option is omitted in a rule (and \fB\-g\fP
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000313is not used), then matching the rule will have no
Henrik Nordstromc2794132004-01-22 15:04:24 +0000314effect on the packet's fate, but the counters on the rule will be
315incremented.
316.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100317\fB\-g\fP, \fB\-\-goto\fP \fIchain\fP
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000318This specifies that the processing should continue in a user
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100319specified chain. Unlike the \-\-jump option return will not continue
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000320processing in this chain but instead in the chain that called us via
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100321\-\-jump.
Henrik Nordstrom17fc1632005-11-05 09:26:40 +0000322.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100323[\fB!\fP] \fB\-i\fP, \fB\-\-in\-interface\fP \fIname\fP
Matthew Strait403cf6a2004-03-17 14:26:08 +0000324Name of an interface via which a packet was received (only for
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200325packets entering the \fBINPUT\fP, \fBFORWARD\fP and \fBPREROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000326chains). When the "!" argument is used before the interface name, the
327sense is inverted. If the interface name ends in a "+", then any
328interface which begins with this name will match. If this option is
329omitted, any interface name will match.
330.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100331[\fB!\fP] \fB\-o\fP, \fB\-\-out\-interface\fP \fIname\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000332Name of an interface via which a packet is going to be sent (for packets
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200333entering the \fBFORWARD\fP, \fBOUTPUT\fP and \fBPOSTROUTING\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000334chains). When the "!" argument is used before the interface name, the
335sense is inverted. If the interface name ends in a "+", then any
336interface which begins with this name will match. If this option is
337omitted, any interface name will match.
338.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100339[\fB!\fP] \fB\-f\fP, \fB\-\-fragment\fP
Florian Westphalc25defa2013-07-14 19:32:12 +0200340This means that the rule only refers to second and further IPv4 fragments
Henrik Nordstromc2794132004-01-22 15:04:24 +0000341of fragmented packets. Since there is no way to tell the source or
342destination ports of such a packet (or ICMP type), such a packet will
343not match any rules which specify them. When the "!" argument
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100344precedes the "\-f" flag, the rule will only match head fragments, or
Florian Westphalc25defa2013-07-14 19:32:12 +0200345unfragmented packets. This option is IPv4 specific, it is not available
346in ip6tables.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000347.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100348\fB\-c\fP, \fB\-\-set\-counters\fP \fIpackets bytes\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000349This enables the administrator to initialize the packet and byte
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200350counters of a rule (during \fBINSERT\fP, \fBAPPEND\fP, \fBREPLACE\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000351operations).
352.SS "OTHER OPTIONS"
353The following additional options can be specified:
354.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100355\fB\-v\fP, \fB\-\-verbose\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000356Verbose output. This option makes the list command show the interface
357name, the rule options (if any), and the TOS masks. The packet and
358byte counters are also listed, with the suffix 'K', 'M' or 'G' for
3591000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100360the \fB\-x\fP flag to change this).
Henrik Nordstromc2794132004-01-22 15:04:24 +0000361For appending, insertion, deletion and replacement, this causes
Jan Engelhardt1c9508e2011-06-30 13:19:15 +0200362detailed information on the rule or rules to be printed. \fB\-v\fP may be
363specified multiple times to possibly emit more detailed debug statements.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000364.TP
Jiri Popelkaaaa4ace2014-07-04 15:50:41 +0200365\fB\-w\fP, \fB\-\-wait\fP [\fIseconds\fP]
Phil Oester93587a02013-05-31 09:07:04 -0400366Wait for the xtables lock.
367To prevent multiple instances of the program from running concurrently,
368an attempt will be made to obtain an exclusive lock at launch. By default,
369the program will exit if the lock cannot be obtained. This option will
Jiri Popelkaaaa4ace2014-07-04 15:50:41 +0200370make the program wait (indefinitely or for optional \fIseconds\fP) until
371the exclusive lock can be obtained.
Phil Oester93587a02013-05-31 09:07:04 -0400372.TP
Subash Abhinov Kasiviswanathane8f857a2016-06-23 18:44:06 -0600373\fB\-W\fP, \fB\-\-wait-interval\fP \fImicroseconds\fP
374Interval to wait per each iteration.
375When running latency sensitive applications, waiting for the xtables lock
376for extended durations may not be acceptable. This option will make each
377iteration take the amount of time specified. The default interval is
3781 second. This option only works with \fB\-w\fP.
379.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100380\fB\-n\fP, \fB\-\-numeric\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000381Numeric output.
382IP addresses and port numbers will be printed in numeric format.
383By default, the program will try to display them as host names,
384network names, or services (whenever applicable).
385.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100386\fB\-x\fP, \fB\-\-exact\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000387Expand numbers.
388Display the exact value of the packet and byte counters,
389instead of only the rounded number in K's (multiples of 1000)
390M's (multiples of 1000K) or G's (multiples of 1000M). This option is
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100391only relevant for the \fB\-L\fP command.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000392.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100393\fB\-\-line\-numbers\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000394When listing rules, add line numbers to the beginning of each rule,
395corresponding to that rule's position in the chain.
396.TP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100397\fB\-\-modprobe=\fP\fIcommand\fP
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200398When adding or inserting rules into a chain, use \fIcommand\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000399to load any necessary modules (targets, match extensions, etc).
Jan Engelhardt44968012012-09-28 10:43:06 +0200400.SH MATCH AND TARGET EXTENSIONS
Jan Engelhardt70af5592011-12-18 02:44:05 +0100401.PP
Jan Engelhardt44968012012-09-28 10:43:06 +0200402iptables can use extended packet matching and target modules.
403A list of these is available in the \fBiptables\-extensions\fP(8) manpage.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000404.SH DIAGNOSTICS
405Various error messages are printed to standard error. The exit code
406is 0 for correct functioning. Errors which appear to be caused by
407invalid or abused command line parameters cause an exit code of 2, and
408other errors cause an exit code of 1.
409.SH BUGS
410Bugs? What's this? ;-)
Harald Welte64d900f2005-06-24 16:37:00 +0000411Well, you might want to have a look at http://bugzilla.netfilter.org/
Henrik Nordstromc2794132004-01-22 15:04:24 +0000412.SH COMPATIBILITY WITH IPCHAINS
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200413This \fBiptables\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000414is very similar to ipchains by Rusty Russell. The main difference is
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200415that the chains \fBINPUT\fP and \fBOUTPUT\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000416are only traversed for packets coming into the local host and
417originating from the local host respectively. Hence every packet only
418passes through one of the three chains (except loopback traffic, which
419involves both INPUT and OUTPUT chains); previously a forwarded packet
420would pass through all three.
421.PP
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100422The other main difference is that \fB\-i\fP refers to the input interface;
423\fB\-o\fP refers to the output interface, and both are available for packets
Jan Engelhardt55dffef2008-07-03 20:27:50 +0200424entering the \fBFORWARD\fP chain.
425.PP
426The various forms of NAT have been separated out; \fBiptables\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000427is a pure packet filter when using the default `filter' table, with
428optional extension modules. This should simplify much of the previous
429confusion over the combination of IP masquerading and packet filtering
430seen previously. So the following options are handled differently:
431.nf
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100432 \-j MASQ
433 \-M \-S
434 \-M \-L
Henrik Nordstromc2794132004-01-22 15:04:24 +0000435.fi
436There are several other changes in iptables.
437.SH SEE ALSO
Jan Engelhardt7b5ba432012-09-28 10:57:45 +0200438\fBiptables\-apply\fP(8),
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100439\fBiptables\-save\fP(8),
440\fBiptables\-restore\fP(8),
Jan Engelhardt44968012012-09-28 10:43:06 +0200441\fBiptables\-extensions\fP(8),
Jan Engelhardt0e8984a2009-01-12 07:06:12 +0100442.PP
Henrik Nordstromc2794132004-01-22 15:04:24 +0000443The packet-filtering-HOWTO details iptables usage for
444packet filtering, the NAT-HOWTO details NAT,
445the netfilter-extensions-HOWTO details the extensions that are
446not in the standard distribution,
447and the netfilter-hacking-HOWTO details the netfilter internals.
448.br
449See
450.BR "http://www.netfilter.org/" .
451.SH AUTHORS
Harald Welte7bdfca42005-07-28 15:24:02 +0000452Rusty Russell originally wrote iptables, in early consultation with Michael
Henrik Nordstromc2794132004-01-22 15:04:24 +0000453Neuling.
454.PP
455Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
456selection framework in iptables, then wrote the mangle table, the owner match,
457the mark stuff, and ran around doing cool stuff everywhere.
458.PP
459James Morris wrote the TOS target, and tos match.
460.PP
461Jozsef Kadlecsik wrote the REJECT target.
462.PP
Harald Welte7bdfca42005-07-28 15:24:02 +0000463Harald 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 +0000464.PP
Pablo Neira Ayuso1a519e82014-03-07 18:40:41 +0100465The Netfilter Core Team is: Jozsef Kadlecsik, Patrick McHardy, Pablo Neira
466Ayuso, Eric Leblond and Florian Westphal. Emeritus Core Team members are: Marc
467Boucher, Martin Josefsson, Yasuyuki Kozakai, James Morris, Harald Welte and
468Rusty Russell.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000469.PP
Harald Welte7bdfca42005-07-28 15:24:02 +0000470Man page originally written by Herve Eychenne <rv@wallfire.org>.
Henrik Nordstromc2794132004-01-22 15:04:24 +0000471.\" .. and did I mention that we are incredibly cool people?
472.\" .. sexy, too ..
473.\" .. witty, charming, powerful ..
474.\" .. and most of all, modest ..
Jan Engelhardtf96cb802011-03-01 12:51:21 +0100475.SH VERSION
476.PP
Jiri Popelka02cf06e2014-03-07 16:23:03 +0100477This manual page applies to iptables/ip6tables @PACKAGE_VERSION@.