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