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