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