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