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