1 .TH IP6TABLES 8 "Mar 09, 2002" "" ""
3 .\" Man page written by Andras Kis-Szabo <kisza@sch.bme.hu>
4 .\" It is based on iptables man page.
6 .\" iptables page by Herve Eychenne <rv@wallfire.org>
7 .\" It is based on ipchains man page.
9 .\" ipchains page by Paul ``Rusty'' Russell March 1997
10 .\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl>
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.
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.
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.
28 ip6tables \- IPv6 packet filter administration
30 .BR "ip6tables [-t table] -[AD] " "chain rule-specification [options]"
32 .BR "ip6tables [-t table] -I " "chain [rulenum] rule-specification [options]"
34 .BR "ip6tables [-t table] -R " "chain rulenum rule-specification [options]"
36 .BR "ip6tables [-t table] -D " "chain rulenum [options]"
38 .BR "ip6tables [-t table] -[LFZ] " "[chain] [options]"
40 .BR "ip6tables [-t table] -N " "chain"
42 .BR "ip6tables [-t table] -X " "[chain]"
44 .BR "ip6tables [-t table] -P " "chain target [options]"
46 .BR "ip6tables [-t table] -E " "old-chain-name new-chain-name"
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.
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
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
72 means to let the packet through.
74 means to drop the packet on the floor.
76 means to pass the packet to userspace (if supported by the kernel).
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
82 is matched, the target specified by the chain policy determines the
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.
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.
95 The tables are as follows:
99 This is the default table (if no -t option is passed). It contains
102 (for packets coming into the box itself),
104 (for packets being routed through the box), and
106 (for locally-generated packets).
109 This table is used for specialized packet alteration. Until kernel
110 2.4.17 it had two built-in chains:
112 (for altering incoming packets before routing) and
114 (for altering locally-generated packets before routing).
115 Since kernel 2.4.18, three other built-in chains are also supported:
117 (for packets coming into the box itself),
119 (for altering packets being routed through the box), and
121 (for altering packets as they are about to go out).
124 The options that are recognized by
126 can be divided into several different groups.
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
133 can differentiate it from all other options.
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.
140 .BI "-D, --delete " "chain rule-specification"
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.
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
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.
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
164 ip6tables -t mangle -n -L
166 Please note that it is often used with the
168 option, in order to avoid long reverse DNS lookups.
169 It is legal to specify the
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
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.
182 .BR "-Z, --zero " "[\fIchain\fP]"
183 Zero the packet and byte counters in all chains. It is legal to
186 (list) option as well, to see the counters immediately before they are
187 cleared. (See above.)
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.
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.
199 .BI "-P, --policy " "chain target"
200 Set the policy for the chain to the given target. See the section
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
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.
212 Give a (currently very brief) description of the command syntax.
214 The following parameters make up a rule specification (as used in the
215 add, delete, insert, replace and append commands).
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
222 .IR ipv6-icmp|icmpv6 ,
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
232 will match with all protocols and is taken as default when this
235 .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
236 Source specification.
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).
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.
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
253 is an alias for this option.
255 .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
256 Destination specification.
257 See the description of the
259 (source) flag for a detailed description of the syntax. The flag
261 is an alias for this option.
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
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
274 .BR "-i, --in-interface " "[!] \fIname\fP"
275 Name of an interface via which a packet is going to be received (only for
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.
286 .BR "-o, --out-interface " "[!] \fIname\fP"
287 Name of an interface via which a packet is going to be sent (for packets
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.
297 .\" Currently not supported (header-based)
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.
307 .B "-c, --set-counters " "PKTS BYTES"
308 This enables the administrator to initialize the packet and byte
309 counters of a rule (during
315 The following additional options can be specified:
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
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.
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).
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
344 When listing rules, add line numbers to the beginning of each rule,
345 corresponding to that rule's position in the chain.
347 .B "--modprobe=command"
348 When adding or inserting rules into a chain, use
350 to load any necessary modules (targets, match extensions, etc).
352 ip6tables can use extended packet matching modules. These are loaded
353 in two ways: implicitly, when
357 is specified, or with the
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,
368 options after the module has been specified to receive help specific
371 The following are included in the base package, and most of these can
374 to invert the sense of the match.
376 These extensions are loaded if `--protocol tcp' is specified. It
377 provides the following options:
379 .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]"
380 Source port or port range specification. This can either be a service
381 name or a port number. An inclusive range can also be specified,
384 If the first port is omitted, "0" is assumed; if the last is omitted,
386 If the second port greater then the first they will be swapped.
389 is a convenient alias for this option.
391 .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]"
392 Destination port or port range specification. The flag
394 is a convenient alias for this option.
396 .BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP"
397 Match when the TCP flags are as specified. The first argument is the
398 flags which we should examine, written as a comma-separated list, and
399 the second argument is a comma-separated list of flags which must be
401 .BR "SYN ACK FIN RST URG PSH ALL NONE" .
404 ip6tables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
406 will only match packets with the SYN flag set, and the ACK, FIN and
410 Only match TCP packets with the SYN bit set and the ACK and RST bits
411 cleared. Such packets are used to request TCP connection initiation;
412 for example, blocking such packets coming in an interface will prevent
413 incoming TCP connections, but outgoing TCP connections will be
415 It is equivalent to \fB--tcp-flags SYN,RST,ACK SYN\fP.
416 If the "!" flag precedes the "--syn", the sense of the
419 .BR "--tcp-option " "[!] \fInumber\fP"
420 Match if TCP option set.
422 These extensions are loaded if `--protocol udp' is specified. It
423 provides the following options:
425 .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]"
426 Source port or port range specification.
427 See the description of the
429 option of the TCP extension for details.
431 .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]"
432 Destination port or port range specification.
433 See the description of the
434 .B --destination-port
435 option of the TCP extension for details.
437 This extension is loaded if `--protocol ipv6-icmp' or `--protocol icmpv6' is
438 specified. It provides the following option:
440 .BR "--icmpv6-type " "[!] \fItypename\fP"
441 This allows specification of the ICMP type, which can be a numeric
442 IPv6-ICMP type, or one of the IPv6-ICMP type names shown by the command
444 ip6tables -p ipv6-icmp -h
448 .BR "--mac-source " "[!] \fIaddress\fP"
449 Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX.
450 Note that this only makes sense for packets coming from an Ethernet device
458 This module matches at a limited rate using a token bucket filter.
459 A rule using this extension will match until this limit is reached
460 (unless the `!' flag is used). It can be used in combination with the
462 target to give limited logging, for example.
464 .BI "--limit " "rate"
465 Maximum average matching rate: specified as a number, with an optional
466 `/second', `/minute', `/hour', or `/day' suffix; the default is
469 .BI "--limit-burst " "number"
470 Maximum initial number of packets to match: this number gets
471 recharged by one every time the limit specified above is not reached,
472 up to this number; the default is 5.
474 This module matches a set of source or destination ports. Up to 15
475 ports can be specified. It can only be used in conjunction with
480 .BR "--source-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
481 Match if the source port is one of the given ports. The flag
483 is a convenient alias for this option.
485 .BR "--destination-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
486 Match if the destination port is one of the given ports. The flag
488 is a convenient alias for this option.
490 .BR "--ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
491 Match if the both the source and destination ports are equal to each
492 other and to one of the given ports.
494 This module matches the netfilter mark field associated with a packet
495 (which can be set using the
499 .BR "--mark " "\fIvalue\fP[/\fImask\fP]"
500 Matches packets with the given unsigned mark value (if a mask is
501 specified, this is logically ANDed with the mask before the
504 This module attempts to match various characteristics of the packet
505 creator, for locally-generated packets. It is only valid in the
507 chain, and even this some packets (such as ICMP ping responses) may
508 have no owner, and hence never match. This is regarded as experimental.
510 .BI "--uid-owner " "userid"
511 Matches if the packet was created by a process with the given
514 .BI "--gid-owner " "groupid"
515 Matches if the packet was created by a process with the given
518 .BI "--pid-owner " "processid"
519 Matches if the packet was created by a process with the given
522 .BI "--sid-owner " "sessionid"
523 Matches if the packet was created by a process in the given session
526 .\" This module, when combined with connection tracking, allows access to
527 .\" the connection tracking state for this packet.
529 .\" .BI "--state " "state"
530 .\" Where state is a comma separated list of the connection states to
531 .\" match. Possible states are
533 .\" meaning that the packet is associated with no known connection,
535 .\" meaning that the packet is associated with a connection which has seen
536 .\" packets in both directions,
538 .\" meaning that the packet has started a new connection, or otherwise
539 .\" associated with a connection which has not seen packets in both
542 .\" meaning that the packet is starting a new connection, but is
543 .\" associated with an existing connection, such as an FTP data transfer,
544 .\" or an ICMP error.
546 .\" This module takes no options, but attempts to match packets which seem
547 .\" malformed or unusual. This is regarded as experimental.
549 .\" This module matches the 8 bits of Type of Service field in the IP
550 .\" header (ie. including the precedence bits).
552 .\" .BI "--tos " "tos"
553 .\" The argument is either a standard name, (use
555 .\" iptables -m tos -h
557 .\" to see the list), or a numeric value to match.
558 .SH TARGET EXTENSIONS
559 ip6tables can use extended target modules: the following are included
560 in the standard distribution.
562 Turn on kernel logging of matching packets. When this option is set
563 for a rule, the Linux kernel will print some information on all
564 matching packets (like most IPv6 IPv6-header fields) via the kernel log
565 (where it can be read with
569 This is a "non-terminating target", i.e. rule traversal continues at
570 the next rule. So if you want to LOG the packets you refuse, use two
571 separate rules with the same matching criteria, first using target LOG
572 then DROP (or REJECT).
574 .BI "--log-level " "level"
575 Level of logging (numeric or see \fIsyslog.conf\fP(5)).
577 .BI "--log-prefix " "prefix"
578 Prefix log messages with the specified prefix; up to 29 letters long,
579 and useful for distinguishing messages in the logs.
581 .B --log-tcp-sequence
582 Log TCP sequence numbers. This is a security risk if the log is
586 Log options from the TCP packet header.
589 Log options from the IPv6 packet header.
591 This is used to set the netfilter mark value associated with the
592 packet. It is only valid in the
596 .BI "--set-mark " "mark"
598 This is used to send back an error packet in response to the matched
599 packet: otherwise it is equivalent to
601 so it is a terminating TARGET, ending rule traversal.
602 This target is only valid in the
607 chains, and user-defined chains which are only called from those
608 chains. The following option controls the nature of the error packet
611 .BI "--reject-with " "type"
612 The type given can be
616 .B " icmp6-adm-prohibited"
618 .B " icmp6-addr-unreachable"
620 .B " icmp6-port-unreachable"
623 which return the appropriate IPv6-ICMP error message (\fBport-unreach\fP is
624 the default). Finally, the option
626 can be used on rules which only match the TCP protocol: this causes a
627 TCP RST packet to be sent back. This is mainly useful for blocking
629 (113/tcp) probes which frequently occur when sending mail to broken mail
630 hosts (which won't accept your mail otherwise).
632 .\" This is used to set the 8-bit Type of Service field in the IP header.
633 .\" It is only valid in the
637 .\" .BI "--set-tos " "tos"
638 .\" You can use a numeric TOS values, or use
640 .\" iptables -j TOS -h
642 .\" to see the list of valid TOS names.
644 .\" This is an experimental demonstration target which inverts the source
645 .\" and destination fields in the IP header and retransmits the packet.
646 .\" It is only valid in the
651 .\" chains, and user-defined chains which are only called from those
652 .\" chains. Note that the outgoing packets are
654 .\" seen by any packet filtering chains, connection tracking or NAT, to
655 .\" avoid loops and other problems.
657 .\" This target is only valid in the
661 .\" chain. It specifies that the source address of the packet should be
662 .\" modified (and all future packets in this connection will also be
663 .\" mangled), and rules should cease being examined. It takes one option:
665 .\" .BR "--to-source " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]"
666 .\" which can specify a single new source IP address, an inclusive range
667 .\" of IP addresses, and optionally, a port range (which is only valid if
668 .\" the rule also specifies
672 .\" If no port range is specified, then source ports below 512 will be
673 .\" mapped to other ports below 512: those between 512 and 1023 inclusive
674 .\" will be mapped to ports below 1024, and other ports will be mapped to
675 .\" 1024 or above. Where possible, no port alteration will occur.
677 .\" This target is only valid in the
683 .\" chains, and user-defined chains which are only called from those
684 .\" chains. It specifies that the destination address of the packet
685 .\" should be modified (and all future packets in this connection will
686 .\" also be mangled), and rules should cease being examined. It takes one
689 .\" .BR "--to-destination " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]"
690 .\" which can specify a single new destination IP address, an inclusive
691 .\" range of IP addresses, and optionally, a port range (which is only
692 .\" valid if the rule also specifies
696 .\" If no port range is specified, then the destination port will never be
699 .\" This target is only valid in the
703 .\" chain. It should only be used with dynamically assigned IP (dialup)
704 .\" connections: if you have a static IP address, you should use the SNAT
705 .\" target. Masquerading is equivalent to specifying a mapping to the IP
706 .\" address of the interface the packet is going out, but also has the
707 .\" effect that connections are
709 .\" when the interface goes down. This is the correct behavior when the
710 .\" next dialup is unlikely to have the same interface address (and hence
711 .\" any established connections are lost anyway). It takes one option:
713 .\" .BR "--to-ports " "\fIport\fP[-\fIport\fP]"
714 .\" This specifies a range of source ports to use, overriding the default
716 .\" source port-selection heuristics (see above). This is only valid
717 .\" if the rule also specifies
722 .\" This target is only valid in the
728 .\" chains, and user-defined chains which are only called from those
729 .\" chains. It alters the destination IP address to send the packet to
730 .\" the machine itself (locally-generated packets are mapped to the
731 .\" 127.0.0.1 address). It takes one option:
733 .\" .BR "--to-ports " "\fIport\fP[-\fIport\fP]"
734 .\" This specifies a destination port or range of ports to use: without
735 .\" this, the destination port is never altered. This is only valid
736 .\" if the rule also specifies
741 Various error messages are printed to standard error. The exit code
742 is 0 for correct functioning. Errors which appear to be caused by
743 invalid or abused command line parameters cause an exit code of 2, and
744 other errors cause an exit code of 1.
746 Bugs? What's this? ;-)
747 Well... the counters are not reliable on sparc64.
748 .SH COMPATIBILITY WITH IPCHAINS
751 is very similar to ipchains by Rusty Russell. The main difference is
756 are only traversed for packets coming into the local host and
757 originating from the local host respectively. Hence every packet only
758 passes through one of the three chains (except loopback traffic, which
759 involves both INPUT and OUTPUT chains); previously a forwarded packet
760 would pass through all three.
762 The other main difference is that
764 refers to the input interface;
766 refers to the output interface, and both are available for packets
770 .\" .PP The various forms of NAT have been separated out;
772 .\" is a pure packet filter when using the default `filter' table, with
773 .\" optional extension modules. This should simplify much of the previous
774 .\" confusion over the combination of IP masquerading and packet filtering
775 .\" seen previously. So the following options are handled differently:
783 There are several other changes in ip6tables.
785 .BR ip6tables-save (8),
786 .BR ip6tables-restore(8),
788 .BR iptables-save (8),
789 .BR iptables-restore (8).
791 The packet-filtering-HOWTO details iptables usage for
792 packet filtering, the NAT-HOWTO details NAT,
793 the netfilter-extensions-HOWTO details the extensions that are
794 not in the standard distribution,
795 and the netfilter-hacking-HOWTO details the netfilter internals.
798 .BR "http://www.netfilter.org/" .
800 Rusty Russell wrote iptables, in early consultation with Michael
803 Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
804 selection framework in iptables, then wrote the mangle table, the owner match,
805 the mark stuff, and ran around doing cool stuff everywhere.
807 James Morris wrote the TOS target, and tos match.
809 Jozsef Kadlecsik wrote the REJECT target.
811 Harald Welte wrote the ULOG target, TTL match+target and libipulog.
813 The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Jozsef Kadlecsik,
814 James Morris, Harald Welte and Rusty Russell.
816 ip6tables man page created by Andras Kis-Szabo, based on
817 iptables man page written by Herve Eychenne <rv@wallfire.org>.
818 .\" .. and did I mention that we are incredibly cool people?
820 .\" .. witty, charming, powerful ..
821 .\" .. and most of all, modest ..