Fix up to work with IVI kernel-headers
[profile/ivi/iptables.git] / iptables.8.in
1 .TH IPTABLES 8 "" "@PACKAGE_AND_VERSION@" "@PACKAGE_AND_VERSION@"
2 .\"
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
26 iptables \(em administration tool for IPv4 packet filtering and NAT
27 .SH SYNOPSIS
28 \fBiptables\fP [\fB\-t\fP \fItable\fP] {\fB\-A\fP|\fB\-D\fP} \fIchain\fP \fIrule-specification\fP
29 .PP
30 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-I\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP
31 .PP
32 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-R\fP \fIchain rulenum rule-specification\fP
33 .PP
34 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-D\fP \fIchain rulenum\fP
35 .PP
36 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-S\fP [\fIchain\fP [\fIrulenum\fP]]
37 .PP
38 \fBiptables\fP [\fB\-t\fP \fItable\fP] {\fB\-F\fP|\fB\-L\fP|\fB\-Z\fP} [\fIchain\fP [\fIrulenum\fP]] [\fIoptions...\fP]
39 .PP
40 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-N\fP \fIchain\fP
41 .PP
42 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-X\fP [\fIchain\fP]
43 .PP
44 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-P\fP \fIchain target\fP
45 .PP
46 \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-E\fP \fIold-chain-name new-chain-name\fP
47 .PP
48 rule-specification = [\fImatches...\fP] [\fItarget\fP]
49 .PP
50 match = \fB\-m\fP \fImatchname\fP [\fIper-match-options\fP]
51 .PP
52 target = \fB\-j\fP \fItargetname\fP [\fIper\-target\-options\fP]
53 .SH DESCRIPTION
54 \fBIptables\fP is used to set up, maintain, and inspect the
55 tables of IPv4 packet
56 filter rules in the Linux kernel.  Several different tables
57 may be defined.  Each table contains a number of built-in
58 chains and may also contain user-defined chains.
59 .PP
60 Each chain is a list of rules which can match a set of packets.  Each
61 rule specifies what to do with a packet that matches.  This is called
62 a `target', which may be a jump to a user-defined chain in the same
63 table.
64 .SH TARGETS
65 A firewall rule specifies criteria for a packet and a target.  If the
66 packet does not match, the next rule in the chain is the examined; if
67 it does match, then the next rule is specified by the value of the
68 target, which can be the name of a user-defined chain or one of the
69 special values \fBACCEPT\fP, \fBDROP\fP, \fBQUEUE\fP or \fBRETURN\fP.
70 .PP
71 \fBACCEPT\fP means to let the packet through.
72 \fBDROP\fP means to drop the packet on the floor.
73 \fBQUEUE\fP means to pass the packet to userspace.
74 (How the packet can be received
75 by a userspace process differs by the particular queue handler.  2.4.x
76 and 2.6.x kernels up to 2.6.13 include the \fBip_queue\fP
77 queue handler.  Kernels 2.6.14 and later additionally include the
78 \fBnfnetlink_queue\fP queue handler.  Packets with a target of QUEUE will be
79 sent to queue number '0' in this case. Please also see the \fBNFQUEUE\fP
80 target as described later in this man page.)
81 \fBRETURN\fP means stop traversing this chain and resume at the next
82 rule in the
83 previous (calling) chain.  If the end of a built-in chain is reached
84 or a rule in a built-in chain with target \fBRETURN\fP
85 is matched, the target specified by the chain policy determines the
86 fate of the packet.
87 .SH TABLES
88 There are currently three independent tables (which tables are present
89 at any time depends on the kernel configuration options and which
90 modules are present).
91 .TP
92 \fB\-t\fP, \fB\-\-table\fP \fItable\fP
93 This option specifies the packet matching table which the command
94 should operate on.  If the kernel is configured with automatic module
95 loading, an attempt will be made to load the appropriate module for
96 that table if it is not already there.
97
98 The tables are as follows:
99 .RS
100 .TP .4i
101 \fBfilter\fP:
102 This is the default table (if no \-t option is passed). It contains
103 the built-in chains \fBINPUT\fP (for packets destined to local sockets),
104 \fBFORWARD\fP (for packets being routed through the box), and
105 \fBOUTPUT\fP (for locally-generated packets).
106 .TP
107 \fBnat\fP:
108 This table is consulted when a packet that creates a new
109 connection is encountered.  It consists of three built-ins: \fBPREROUTING\fP
110 (for altering packets as soon as they come in), \fBOUTPUT\fP
111 (for altering locally-generated packets before routing), and \fBPOSTROUTING\fP
112 (for altering packets as they are about to go out).
113 .TP
114 \fBmangle\fP:
115 This table is used for specialized packet alteration.  Until kernel
116 2.4.17 it had two built-in chains: \fBPREROUTING\fP
117 (for altering incoming packets before routing) and \fBOUTPUT\fP
118 (for altering locally-generated packets before routing).
119 Since kernel 2.4.18, three other built-in chains are also supported:
120 \fBINPUT\fP (for packets coming into the box itself), \fBFORWARD\fP
121 (for altering packets being routed through the box), and \fBPOSTROUTING\fP
122 (for altering packets as they are about to go out).
123 .TP
124 \fBraw\fP:
125 This table is used mainly for configuring exemptions from connection
126 tracking in combination with the NOTRACK target.  It registers at the netfilter
127 hooks with higher priority and is thus called before ip_conntrack, or any other
128 IP tables.  It provides the following built-in chains: \fBPREROUTING\fP
129 (for packets arriving via any network interface) \fBOUTPUT\fP
130 (for packets generated by local processes)
131 .RE
132 .SH OPTIONS
133 The options that are recognized by
134 \fBiptables\fP can be divided into several different groups.
135 .SS COMMANDS
136 These options specify the desired action to perform. Only one of them
137 can be specified on the command line unless otherwise stated
138 below. For long versions of the command and option names, you
139 need to use only enough letters to ensure that
140 \fBiptables\fP can differentiate it from all other options.
141 .TP
142 \fB\-A\fP, \fB\-\-append\fP \fIchain rule-specification\fP
143 Append one or more rules to the end of the selected chain.
144 When the source and/or destination names resolve to more than one
145 address, a rule will be added for each possible address combination.
146 .TP
147 \fB\-D\fP, \fB\-\-delete\fP \fIchain rule-specification\fP
148 .ns
149 .TP
150 \fB\-D\fP, \fB\-\-delete\fP \fIchain rulenum\fP
151 Delete one or more rules from the selected chain.  There are two
152 versions of this command: the rule can be specified as a number in the
153 chain (starting at 1 for the first rule) or a rule to match.
154 .TP
155 \fB\-I\fP, \fB\-\-insert\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP
156 Insert one or more rules in the selected chain as the given rule
157 number.  So, if the rule number is 1, the rule or rules are inserted
158 at the head of the chain.  This is also the default if no rule number
159 is specified.
160 .TP
161 \fB\-R\fP, \fB\-\-replace\fP \fIchain rulenum rule-specification\fP
162 Replace a rule in the selected chain.  If the source and/or
163 destination names resolve to multiple addresses, the command will
164 fail.  Rules are numbered starting at 1.
165 .TP
166 \fB\-L\fP, \fB\-\-list\fP [\fIchain\fP]
167 List all rules in the selected chain.  If no chain is selected, all
168 chains are listed. Like every other iptables command, it applies to the
169 specified table (filter is the default), so NAT rules get listed by
170 .nf
171  iptables \-t nat \-n \-L
172 .fi
173 Please note that it is often used with the \fB\-n\fP
174 option, in order to avoid long reverse DNS lookups.
175 It is legal to specify the \fB\-Z\fP
176 (zero) option as well, in which case the chain(s) will be atomically
177 listed and zeroed.  The exact output is affected by the other
178 arguments given. The exact rules are suppressed until you use
179 .nf
180  iptables \-L \-v
181 .fi
182 .TP
183 \fB\-S\fP, \fB\-\-list\-rules\fP [\fIchain\fP]
184 Print all rules in the selected chain.  If no chain is selected, all
185 chains are printed like iptables-save. Like every other iptables command,
186 it applies to the specified table (filter is the default).
187 .TP
188 \fB\-F\fP, \fB\-\-flush\fP [\fIchain\fP]
189 Flush the selected chain (all the chains in the table if none is given).
190 This is equivalent to deleting all the rules one by one.
191 .TP
192 \fB\-Z\fP, \fB\-\-zero\fP [\fIchain\fP [\fIrulenum\fP]]
193 Zero the packet and byte counters in all chains, or only the given chain,
194 or only the given rule in a chain. It is legal to
195 specify the
196 \fB\-L\fP, \fB\-\-list\fP
197 (list) option as well, to see the counters immediately before they are
198 cleared. (See above.)
199 .TP
200 \fB\-N\fP, \fB\-\-new\-chain\fP \fIchain\fP
201 Create a new user-defined chain by the given name.  There must be no
202 target of that name already.
203 .TP
204 \fB\-X\fP, \fB\-\-delete\-chain\fP [\fIchain\fP]
205 Delete the optional user-defined chain specified.  There must be no references
206 to the chain.  If there are, you must delete or replace the referring rules
207 before the chain can be deleted.  The chain must be empty, i.e. not contain
208 any rules.  If no argument is given, it will attempt to delete every
209 non-builtin chain in the table.
210 .TP
211 \fB\-P\fP, \fB\-\-policy\fP \fIchain target\fP
212 Set the policy for the chain to the given target.  See the section \fBTARGETS\fP
213 for the legal targets.  Only built-in (non-user-defined) chains can have
214 policies, and neither built-in nor user-defined chains can be policy
215 targets.
216 .TP
217 \fB\-E\fP, \fB\-\-rename\-chain\fP \fIold\-chain new\-chain\fP
218 Rename the user specified chain to the user supplied name.  This is
219 cosmetic, and has no effect on the structure of the table.
220 .TP
221 \fB\-h\fP
222 Help.
223 Give a (currently very brief) description of the command syntax.
224 .SS PARAMETERS
225 The following parameters make up a rule specification (as used in the
226 add, delete, insert, replace and append commands).
227 .TP
228 [\fB!\fP] \fB\-p\fP, \fB\-\-protocol\fP \fIprotocol\fP
229 The protocol of the rule or of the packet to check.
230 The specified protocol can be one of \fBtcp\fP, \fBudp\fP, \fBudplite\fP,
231 \fBicmp\fP, \fBesp\fP, \fBah\fP, \fBsctp\fP or \fBall\fP,
232 or it can be a numeric value, representing one of these protocols or a
233 different one.  A protocol name from /etc/protocols is also allowed.
234 A "!" argument before the protocol inverts the
235 test.  The number zero is equivalent to \fBall\fP.
236 Protocol \fBall\fP
237 will match with all protocols and is taken as default when this
238 option is omitted.
239 .TP
240 [\fB!\fP] \fB\-s\fP, \fB\-\-source\fP \fIaddress\fP[\fB/\fP\fImask\fP][\fB,\fP\fI...\fP]
241 Source specification. \fIAddress\fP
242 can be either a network name, a hostname, a network IP address (with
243 \fB/\fP\fImask\fP), or a plain IP address. Hostnames will
244 be resolved once only, before the rule is submitted to the kernel.
245 Please note that specifying any name to be resolved with a remote query such as
246 DNS is a really bad idea.
247 The \fImask\fP
248 can be either a network mask or a plain number,
249 specifying the number of 1's at the left side of the network mask.
250 Thus, a mask of \fI24\fP is equivalent to \fI255.255.255.0\fP.
251 A "!" argument before the address specification inverts the sense of
252 the address. The flag \fB\-\-src\fP is an alias for this option.
253 Multiple addresses can be specified, but this will \fBexpand to multiple
254 rules\fP (when adding with \-A), or will cause multiple rules to be
255 deleted (with \-D).
256 .TP
257 [\fB!\fP] \fB\-d\fP, \fB\-\-destination\fP \fIaddress\fP[\fB/\fP\fImask\fP][\fB,\fP\fI...\fP]
258 Destination specification. 
259 See the description of the \fB\-s\fP
260 (source) flag for a detailed description of the syntax.  The flag
261 \fB\-\-dst\fP is an alias for this option.
262 .TP
263 \fB\-j\fP, \fB\-\-jump\fP \fItarget\fP
264 This specifies the target of the rule; i.e., what to do if the packet
265 matches it.  The target can be a user-defined chain (other than the
266 one this rule is in), one of the special builtin targets which decide
267 the fate of the packet immediately, or an extension (see \fBEXTENSIONS\fP
268 below).  If this
269 option is omitted in a rule (and \fB\-g\fP
270 is not used), then matching the rule will have no
271 effect on the packet's fate, but the counters on the rule will be
272 incremented.
273 .TP
274 \fB\-g\fP, \fB\-\-goto\fP \fIchain\fP
275 This specifies that the processing should continue in a user
276 specified chain. Unlike the \-\-jump option return will not continue
277 processing in this chain but instead in the chain that called us via
278 \-\-jump.
279 .TP
280 [\fB!\fP] \fB\-i\fP, \fB\-\-in\-interface\fP \fIname\fP
281 Name of an interface via which a packet was received (only for
282 packets entering the \fBINPUT\fP, \fBFORWARD\fP and \fBPREROUTING\fP
283 chains).  When the "!" argument is used before the interface name, the
284 sense is inverted.  If the interface name ends in a "+", then any
285 interface which begins with this name will match.  If this option is
286 omitted, any interface name will match.
287 .TP
288 [\fB!\fP] \fB\-o\fP, \fB\-\-out\-interface\fP \fIname\fP
289 Name of an interface via which a packet is going to be sent (for packets
290 entering the \fBFORWARD\fP, \fBOUTPUT\fP and \fBPOSTROUTING\fP
291 chains).  When the "!" argument is used before the interface name, the
292 sense is inverted.  If the interface name ends in a "+", then any
293 interface which begins with this name will match.  If this option is
294 omitted, any interface name will match.
295 .TP
296 [\fB!\fP] \fB\-f\fP, \fB\-\-fragment\fP
297 This means that the rule only refers to second and further fragments
298 of fragmented packets.  Since there is no way to tell the source or
299 destination ports of such a packet (or ICMP type), such a packet will
300 not match any rules which specify them.  When the "!" argument
301 precedes the "\-f" flag, the rule will only match head fragments, or
302 unfragmented packets.
303 .TP
304 \fB\-c\fP, \fB\-\-set\-counters\fP \fIpackets bytes\fP
305 This enables the administrator to initialize the packet and byte
306 counters of a rule (during \fBINSERT\fP, \fBAPPEND\fP, \fBREPLACE\fP
307 operations).
308 .SS "OTHER OPTIONS"
309 The following additional options can be specified:
310 .TP
311 \fB\-v\fP, \fB\-\-verbose\fP
312 Verbose output.  This option makes the list command show the interface
313 name, the rule options (if any), and the TOS masks.  The packet and
314 byte counters are also listed, with the suffix 'K', 'M' or 'G' for
315 1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
316 the \fB\-x\fP flag to change this).
317 For appending, insertion, deletion and replacement, this causes
318 detailed information on the rule or rules to be printed.
319 .TP
320 \fB\-n\fP, \fB\-\-numeric\fP
321 Numeric output.
322 IP addresses and port numbers will be printed in numeric format.
323 By default, the program will try to display them as host names,
324 network names, or services (whenever applicable).
325 .TP
326 \fB\-x\fP, \fB\-\-exact\fP
327 Expand numbers.
328 Display the exact value of the packet and byte counters,
329 instead of only the rounded number in K's (multiples of 1000)
330 M's (multiples of 1000K) or G's (multiples of 1000M).  This option is
331 only relevant for the \fB\-L\fP command.
332 .TP
333 \fB\-\-line\-numbers\fP
334 When listing rules, add line numbers to the beginning of each rule,
335 corresponding to that rule's position in the chain.
336 .TP
337 \fB\-\-modprobe=\fP\fIcommand\fP
338 When adding or inserting rules into a chain, use \fIcommand\fP
339 to load any necessary modules (targets, match extensions, etc).
340 .SH MATCH EXTENSIONS
341 iptables can use extended packet matching modules.  These are loaded
342 in two ways: implicitly, when \fB\-p\fP or \fB\-\-protocol\fP
343 is specified, or with the \fB\-m\fP or \fB\-\-match\fP
344 options, followed by the matching module name; after these, various
345 extra command line options become available, depending on the specific
346 module.  You can specify multiple extended match modules in one line,
347 and you can use the \fB\-h\fP or \fB\-\-help\fP
348 options after the module has been specified to receive help specific
349 to that module.
350 .PP
351 The following are included in the base package, and most of these can
352 be preceded by a "\fB!\fP" to invert the sense of the match.
353 .\" @MATCH@
354 .SH TARGET EXTENSIONS
355 iptables can use extended target modules: the following are included
356 in the standard distribution.
357 .\" @TARGET@
358 .SH DIAGNOSTICS
359 Various error messages are printed to standard error.  The exit code
360 is 0 for correct functioning.  Errors which appear to be caused by
361 invalid or abused command line parameters cause an exit code of 2, and
362 other errors cause an exit code of 1.
363 .SH BUGS
364 Bugs?  What's this? ;-)
365 Well, you might want to have a look at http://bugzilla.netfilter.org/
366 .SH COMPATIBILITY WITH IPCHAINS
367 This \fBiptables\fP
368 is very similar to ipchains by Rusty Russell.  The main difference is
369 that the chains \fBINPUT\fP and \fBOUTPUT\fP
370 are only traversed for packets coming into the local host and
371 originating from the local host respectively.  Hence every packet only
372 passes through one of the three chains (except loopback traffic, which
373 involves both INPUT and OUTPUT chains); previously a forwarded packet
374 would pass through all three.
375 .PP
376 The other main difference is that \fB\-i\fP refers to the input interface;
377 \fB\-o\fP refers to the output interface, and both are available for packets
378 entering the \fBFORWARD\fP chain.
379 .PP
380 The various forms of NAT have been separated out; \fBiptables\fP
381 is a pure packet filter when using the default `filter' table, with
382 optional extension modules.  This should simplify much of the previous
383 confusion over the combination of IP masquerading and packet filtering
384 seen previously.  So the following options are handled differently:
385 .nf
386  \-j MASQ
387  \-M \-S
388  \-M \-L
389 .fi
390 There are several other changes in iptables.
391 .SH SEE ALSO
392 \fBiptables\-save\fP(8),
393 \fBiptables\-restore\fP(8),
394 \fBip6tables\fP(8),
395 \fBip6tables\-save\fP(8),
396 \fBip6tables\-restore\fP(8),
397 \fBlibipq\fP(3).
398 .PP
399 The packet-filtering-HOWTO details iptables usage for
400 packet filtering, the NAT-HOWTO details NAT,
401 the netfilter-extensions-HOWTO details the extensions that are
402 not in the standard distribution,
403 and the netfilter-hacking-HOWTO details the netfilter internals.
404 .br
405 See
406 .BR "http://www.netfilter.org/" .
407 .SH AUTHORS
408 Rusty Russell originally wrote iptables, in early consultation with Michael
409 Neuling.
410 .PP
411 Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
412 selection framework in iptables, then wrote the mangle table, the owner match,
413 the mark stuff, and ran around doing cool stuff everywhere.
414 .PP
415 James Morris wrote the TOS target, and tos match.
416 .PP
417 Jozsef Kadlecsik wrote the REJECT target.
418 .PP
419 Harald Welte wrote the ULOG and NFQUEUE target, the new libiptc, as well as the TTL, DSCP, ECN matches and targets.
420 .PP
421 The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Yasuyuki Kozakai,
422 Jozsef Kadlecsik, Patrick McHardy, James Morris, Pablo Neira Ayuso,
423 Harald Welte and Rusty Russell.
424 .PP
425 Man page originally written by Herve Eychenne <rv@wallfire.org>.
426 .\" .. and did I mention that we are incredibly cool people?
427 .\" .. sexy, too ..
428 .\" .. witty, charming, powerful ..
429 .\" .. and most of all, modest ..