1 .TH IPTABLES 8 "Mar 09, 2002" "" ""
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)
7 .\" ipchains page by Paul ``Rusty'' Russell March 1997
8 .\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl>
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.
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.
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.
26 iptables \- administration tool for IPv4 packet filtering and NAT
28 .BR "iptables [-t table] -[AD] " "chain rule-specification [options]"
30 .BR "iptables [-t table] -I " "chain [rulenum] rule-specification [options]"
32 .BR "iptables [-t table] -R " "chain rulenum rule-specification [options]"
34 .BR "iptables [-t table] -D " "chain rulenum [options]"
36 .BR "iptables [-t table] -[LFZ] " "[chain] [options]"
38 .BR "iptables [-t table] -N " "chain"
40 .BR "iptables [-t table] -X " "[chain]"
42 .BR "iptables [-t table] -P " "chain target [options]"
44 .BR "iptables [-t table] -E " "old-chain-name new-chain-name"
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.
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
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
70 means to let the packet through.
72 means to drop the packet on the floor.
74 means to pass the packet to userspace (if supported by the kernel).
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
80 is matched, the target specified by the chain policy determines the
83 There are currently three independent tables (which tables are present
84 at any time depends on the kernel configuration options and which
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.
93 The tables are as follows:
97 This is the default table (if no -t option is passed). It contains
100 (for packets coming into the box itself),
102 (for packets being routed through the box), and
104 (for locally-generated packets).
107 This table is consulted when a packet that creates a new
108 connection is encountered. It consists of three built-ins:
110 (for altering packets as soon as they come in),
112 (for altering locally-generated packets before routing), and
114 (for altering packets as they are about to go out).
117 This table is used for specialized packet alteration. Until kernel
118 2.4.17 it had two built-in chains:
120 (for altering incoming packets before routing) and
122 (for altering locally-generated packets before routing).
123 Since kernel 2.4.18, three other built-in chains are also supported:
125 (for packets coming into the box itself),
127 (for altering packets being routed through the box), and
129 (for altering packets as they are about to go out).
132 The options that are recognized by
134 can be divided into several different groups.
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
141 can differentiate it from all other options.
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.
148 .BI "-D, --delete " "chain rule-specification"
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.
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
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.
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
172 iptables -t nat -n -L
174 Please note that it is often used with the
176 option, in order to avoid long reverse DNS lookups.
177 It is legal to specify the
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
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.
190 .BR "-Z, --zero " "[\fIchain\fP]"
191 Zero the packet and byte counters in all chains. It is legal to
194 (list) option as well, to see the counters immediately before they are
195 cleared. (See above.)
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.
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.
207 .BI "-P, --policy " "chain target"
208 Set the policy for the chain to the given target. See the section
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
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.
220 Give a (currently very brief) description of the command syntax.
222 The following parameters make up a rule specification (as used in the
223 add, delete, insert, replace and append commands).
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
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
240 will match with all protocols and is taken as default when this
243 .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
244 Source specification.
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.
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.
257 A "!" argument before the address specification inverts the sense of
258 the address. The flag
260 is an alias for this option.
262 .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
263 Destination specification.
264 See the description of the
266 (source) flag for a detailed description of the syntax. The flag
268 is an alias for this option.
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
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
281 .BR "-i, --in-interface " "[!] \fIname\fP"
282 Name of an interface via which a packet is going to be received (only for
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.
293 .BR "-o, --out-interface " "[!] \fIname\fP"
294 Name of an interface via which a packet is going to be sent (for packets
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.
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.
313 .BI "-c, --set-counters " "PKTS BYTES"
314 This enables the administrator to initialize the packet and byte
315 counters of a rule (during
321 The following additional options can be specified:
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
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.
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).
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
350 When listing rules, add line numbers to the beginning of each rule,
351 corresponding to that rule's position in the chain.
353 .B "--modprobe=command"
354 When adding or inserting rules into a chain, use
356 to load any necessary modules (targets, match extensions, etc).
358 iptables can use extended packet matching modules. These are loaded
359 in two ways: implicitly, when
363 is specified, or with the
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,
374 options after the module has been specified to receive help specific
377 The following are included in the base package, and most of these can
380 to invert the sense of the match.
382 This module matches the SPIs in AH header of IPSec packets.
384 .BR "--ahspi " "[!] \fIspi\fP[:\fIspi\fP]"
386 This module, when combined with connection tracking, allows access to
387 more connection tracking information than the "state" match.
388 (this module is present only if iptables was compiled under a kernel
389 supporting this feature)
391 .BI "--ctstate " "state"
392 Where state is a comma separated list of the connection states to
393 match. Possible states are
395 meaning that the packet is associated with no known connection,
397 meaning that the packet is associated with a connection which has seen
398 packets in both directions,
400 meaning that the packet has started a new connection, or otherwise
401 associated with a connection which has not seen packets in both
404 meaning that the packet is starting a new connection, but is
405 associated with an existing connection, such as an FTP data transfer,
408 A virtual state, matching if the original source address differs from
409 the reply destination.
411 A virtual state, matching if the original destination differs from the
414 .BI "--ctproto " "proto"
415 Protocol to match (by number or name)
417 .BI "--ctorigsrc " "[!] \fIaddress\fP[/\fImask\fP]"
418 Match against original source address
420 .BI "--ctorigdst " "[!] \fIaddress\fP[/\fImask\fP]"
421 Match against original destination address
423 .BI "--ctreplsrc " "[!] \fIaddress\fP[/\fImask\fP]"
424 Match against reply source address
426 .BI "--ctrepldst " "[!] \fIaddress\fB[/\fImask\fP]"
427 Match against reply destination address
429 .BI "--ctstatus " "[\fINONE|EXPECTED|SEEN_REPLY|ASSURED\fP][,...]"
430 Match against internal conntrack states
432 .BI "--ctexpire " "\fItime\fP[\fI:time\fP]"
433 Match remaining lifetime in seconds against given value
434 or range of values (inclusive)
436 This module matches the 6 bit DSCP field within the TOS field in the
437 IP header. DSCP has superseded TOS within the IETF.
439 .BI "--dscp " "value"
440 Match against a numeric (decimal or hex) value [0-32].
442 .BI "--dscp-class " "\fIDiffServ Class\fP"
443 Match the DiffServ class. This value may be any of the
444 BE, EF, AFxx or CSx classes. It will then be converted
445 into it's according numeric value.
447 This module matches the SPIs in ESP header of IPSec packets.
449 .BR "--espspi " "[!] \fIspi\fP[:\fIspi\fP]"
451 This module matches packets related to a specific conntrack-helper.
453 .BI "--helper " "string"
454 Matches packets related to the specified conntrack-helper.
457 string can be "ftp" for packets related to a ftp-session on default port.
458 For other ports append -portnr to the value, ie. "ftp-2121".
460 Same rules apply for other conntrack-helpers.
463 This extension is loaded if `--protocol icmp' is specified. It
464 provides the following option:
466 .BR "--icmp-type " "[!] \fItypename\fP"
467 This allows specification of the ICMP type, which can be a numeric
468 ICMP type, or one of the ICMP type names shown by the command
473 This module matches the length of a packet against a specific value
476 .BR "--length " "\fIlength\fP[:\fIlength\fP]"
478 This module matches at a limited rate using a token bucket filter.
479 A rule using this extension will match until this limit is reached
480 (unless the `!' flag is used). It can be used in combination with the
482 target to give limited logging, for example.
484 .BI "--limit " "rate"
485 Maximum average matching rate: specified as a number, with an optional
486 `/second', `/minute', `/hour', or `/day' suffix; the default is
489 .BI "--limit-burst " "number"
490 Maximum initial number of packets to match: this number gets
491 recharged by one every time the limit specified above is not reached,
492 up to this number; the default is 5.
495 .BR "--mac-source " "[!] \fIaddress\fP"
496 Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX.
497 Note that this only makes sense for packets coming from an Ethernet device
505 This module matches the netfilter mark field associated with a packet
506 (which can be set using the
510 .BR "--mark " "\fIvalue\fP[/\fImask\fP]"
511 Matches packets with the given unsigned mark value (if a mask is
512 specified, this is logically ANDed with the mask before the
515 This module matches a set of source or destination ports. Up to 15
516 ports can be specified. It can only be used in conjunction with
521 .BR "--source-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
522 Match if the source port is one of the given ports. The flag
524 is a convenient alias for this option.
526 .BR "--destination-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
527 Match if the destination port is one of the given ports. The flag
529 is a convenient alias for this option.
531 .BR "--ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
532 Match if the both the source and destination ports are equal to each
533 other and to one of the given ports.
535 This module attempts to match various characteristics of the packet
536 creator, for locally-generated packets. It is only valid in the
538 chain, and even this some packets (such as ICMP ping responses) may
539 have no owner, and hence never match.
541 .BI "--uid-owner " "userid"
542 Matches if the packet was created by a process with the given
545 .BI "--gid-owner " "groupid"
546 Matches if the packet was created by a process with the given
549 .BI "--pid-owner " "processid"
550 Matches if the packet was created by a process with the given
553 .BI "--sid-owner " "sessionid"
554 Matches if the packet was created by a process in the given session
557 .BI "--cmd-owner " "name"
558 Matches if the packet was created by a process with the given command name.
559 (this option is present only if iptables was compiled under a kernel
560 supporting this feature)
562 This module matches on the bridge port input and output devices enslaved
563 to a bridge device. This module is a part of the infrastructure that enables
564 a transparent bridging IP firewall and is only useful for kernel versions
565 above version 2.5.44.
568 Name of a bridge port via which a packet is received (only for
574 chains). If the interface name ends in a "+", then any
575 interface which begins with this name will match. If the packet didn't arrive
576 through a bridge device, this packet won't match this option, unless '!' is used.
578 .B --physdev-out name
579 Name of a bridge port via which a packet is going to be sent (for packets
585 chains). If the interface name ends in a "+", then any
586 interface which begins with this name will match. Note that in the
587 .BR nat " and " mangle
589 chains one cannot match on the bridge output port, however one can in the
591 chain. If the packet won't leave by a bridge device or it is yet unknown what
592 the output device will be, then the packet won't match this option, unless
596 Matches if the packet has entered through a bridge interface.
599 Matches if the packet will leave through a bridge interface.
601 .B --physdev-is-bridged
602 Matches if the packet is being bridged and therefore is not being routed.
603 This is only useful in the FORWARD and POSTROUTING chains.
605 This module matches the link-layer packet type.
607 .BI "--pkt-type " "[\fIunicast\fP|\fIbroadcast\fP|\fImulticast\fP]"
609 This module, when combined with connection tracking, allows access to
610 the connection tracking state for this packet.
612 .BI "--state " "state"
613 Where state is a comma separated list of the connection states to
614 match. Possible states are
616 meaning that the packet could not be identified for some reason which
617 includes running out of memory and ICMP errors which don't correspond to any
620 meaning that the packet is associated with a connection which has seen
621 packets in both directions,
623 meaning that the packet has started a new connection, or otherwise
624 associated with a connection which has not seen packets in both
627 meaning that the packet is starting a new connection, but is
628 associated with an existing connection, such as an FTP data transfer,
631 These extensions are loaded if `--protocol tcp' is specified. It
632 provides the following options:
634 .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]"
635 Source port or port range specification. This can either be a service
636 name or a port number. An inclusive range can also be specified,
639 If the first port is omitted, "0" is assumed; if the last is omitted,
641 If the second port greater then the first they will be swapped.
644 is a convenient alias for this option.
646 .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]"
647 Destination port or port range specification. The flag
649 is a convenient alias for this option.
651 .BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP"
652 Match when the TCP flags are as specified. The first argument is the
653 flags which we should examine, written as a comma-separated list, and
654 the second argument is a comma-separated list of flags which must be
656 .BR "SYN ACK FIN RST URG PSH ALL NONE" .
659 iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
661 will only match packets with the SYN flag set, and the ACK, FIN and
665 Only match TCP packets with the SYN bit set and the ACK and RST bits
666 cleared. Such packets are used to request TCP connection initiation;
667 for example, blocking such packets coming in an interface will prevent
668 incoming TCP connections, but outgoing TCP connections will be
670 It is equivalent to \fB--tcp-flags SYN,RST,ACK SYN\fP.
671 If the "!" flag precedes the "--syn", the sense of the
674 .BR "--tcp-option " "[!] \fInumber\fP"
675 Match if TCP option set.
677 .BR "--mss " "\fIvalue\fP[:\fIvalue\fP]"
678 Match TCP SYN or SYN/ACK packets with the specified MSS value (or range),
679 which control the maximum packet size for that connection.
681 This module matches the 8 bits of Type of Service field in the IP
682 header (ie. including the precedence bits).
685 The argument is either a standard name, (use
689 to see the list), or a numeric value to match.
691 This module matches the time to live field in the IP header.
694 Matches the given TTL value.
696 These extensions are loaded if `--protocol udp' is specified. It
697 provides the following options:
699 .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]"
700 Source port or port range specification.
701 See the description of the
703 option of the TCP extension for details.
705 .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]"
706 Destination port or port range specification.
707 See the description of the
708 .B --destination-port
709 option of the TCP extension for details.
711 This module takes no options, but attempts to match packets which seem
712 malformed or unusual. This is regarded as experimental.
713 .SH TARGET EXTENSIONS
714 iptables can use extended target modules: the following are included
715 in the standard distribution.
717 This target is only valid in the
723 chains, and user-defined chains which are only called from those
724 chains. It specifies that the destination address of the packet
725 should be modified (and all future packets in this connection will
726 also be mangled), and rules should cease being examined. It takes one
729 .BR "--to-destination " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]"
730 which can specify a single new destination IP address, an inclusive
731 range of IP addresses, and optionally, a port range (which is only
732 valid if the rule also specifies
736 If no port range is specified, then the destination port will never be
740 You can add several --to-destination options. If you specify more
741 than one destination address, either via an address range or multiple
742 --to-destination options, a simple round-robin (one after another in
743 cycle) load balancing takes place between these adresses.
745 This target allows to alter the value of the DSCP bits within the TOS
746 header of the IPv4 packet. As this manipulates a packet, it can only
747 be used in the mangle table.
749 .BI "--set-dscp " "value"
750 Set the DSCP field to a numerical value (can be decimal or hex)
752 .BI "--set-dscp-class " "class"
753 Set the DSCP field to a DiffServ class.
755 This target allows to selectively work around known ECN blackholes.
756 It can only be used in the mangle table.
758 .BI "--ecn-tcp-remove"
759 Remove all ECN bits from the TCP header. Of course, it can only be used
763 Turn on kernel logging of matching packets. When this option is set
764 for a rule, the Linux kernel will print some information on all
765 matching packets (like most IP header fields) via the kernel log
766 (where it can be read with
770 This is a "non-terminating target", i.e. rule traversal continues at
771 the next rule. So if you want to LOG the packets you refuse, use two
772 separate rules with the same matching criteria, first using target LOG
773 then DROP (or REJECT).
775 .BI "--log-level " "level"
776 Level of logging (numeric or see \fIsyslog.conf\fP(5)).
778 .BI "--log-prefix " "prefix"
779 Prefix log messages with the specified prefix; up to 29 letters long,
780 and useful for distinguishing messages in the logs.
782 .B --log-tcp-sequence
783 Log TCP sequence numbers. This is a security risk if the log is
787 Log options from the TCP packet header.
790 Log options from the IP packet header.
792 This is used to set the netfilter mark value associated with the
793 packet. It is only valid in the
795 table. It can for example be used in conjunction with iproute2.
797 .BI "--set-mark " "mark"
799 This target is only valid in the
803 chain. It should only be used with dynamically assigned IP (dialup)
804 connections: if you have a static IP address, you should use the SNAT
805 target. Masquerading is equivalent to specifying a mapping to the IP
806 address of the interface the packet is going out, but also has the
807 effect that connections are
809 when the interface goes down. This is the correct behavior when the
810 next dialup is unlikely to have the same interface address (and hence
811 any established connections are lost anyway). It takes one option:
813 .BR "--to-ports " "\fIport\fP[-\fIport\fP]"
814 This specifies a range of source ports to use, overriding the default
816 source port-selection heuristics (see above). This is only valid
817 if the rule also specifies
822 This is an experimental demonstration target which inverts the source
823 and destination fields in the IP header and retransmits the packet.
824 It is only valid in the
829 chains, and user-defined chains which are only called from those
830 chains. Note that the outgoing packets are
832 seen by any packet filtering chains, connection tracking or NAT, to
833 avoid loops and other problems.
835 This target is only valid in the
841 chains, and user-defined chains which are only called from those
842 chains. It alters the destination IP address to send the packet to
843 the machine itself (locally-generated packets are mapped to the
844 127.0.0.1 address). It takes one option:
846 .BR "--to-ports " "\fIport\fP[-\fIport\fP]"
847 This specifies a destination port or range of ports to use: without
848 this, the destination port is never altered. This is only valid
849 if the rule also specifies
854 This is used to send back an error packet in response to the matched
855 packet: otherwise it is equivalent to
857 so it is a terminating TARGET, ending rule traversal.
858 This target is only valid in the
863 chains, and user-defined chains which are only called from those
864 chains. The following option controls the nature of the error packet
867 .BI "--reject-with " "type"
868 The type given can be
870 .B " icmp-net-unreachable"
871 .B " icmp-host-unreachable"
872 .B " icmp-port-unreachable"
873 .B " icmp-proto-unreachable"
874 .B " icmp-net-prohibited"
875 .B " icmp-host-prohibited or"
876 .B " icmp-admin-prohibited (*)"
878 which return the appropriate ICMP error message (\fBport-unreachable\fP is
879 the default). The option
881 can be used on rules which only match the TCP protocol: this causes a
882 TCP RST packet to be sent back. This is mainly useful for blocking
884 (113/tcp) probes which frequently occur when sending mail to broken mail
885 hosts (which won't accept your mail otherwise).
887 (*) Using icmp-admin-prohibited with kernels that do not support it will result in a plain DROP instead of REJECT
889 This target is only valid in the
893 chain. It specifies that the source address of the packet should be
894 modified (and all future packets in this connection will also be
895 mangled), and rules should cease being examined. It takes one type
898 .BR "--to-source " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]"
899 which can specify a single new source IP address, an inclusive range
900 of IP addresses, and optionally, a port range (which is only valid if
901 the rule also specifies
905 If no port range is specified, then source ports below 512 will be
906 mapped to other ports below 512: those between 512 and 1023 inclusive
907 will be mapped to ports below 1024, and other ports will be mapped to
908 1024 or above. Where possible, no port alteration will occur.
911 You can add several --to-source options. If you specify more
912 than one source address, either via an address range or multiple
913 --to-source options, a simple round-robin (one after another in
914 cycle) takes place between these adresses.
916 This target allows to alter the MSS value of TCP SYN packets, to control
917 the maximum size for that connection (usually limiting it to your
918 outgoing interface's MTU minus 40). Of course, it can only be used
922 This target is used to overcome criminally braindead ISPs or servers
923 which block ICMP Fragmentation Needed packets. The symptoms of this
924 problem are that everything works fine from your Linux
925 firewall/router, but machines behind it can never exchange large
931 Web browsers connect, then hang with no data received.
934 Small mail works fine, but large emails hang.
937 ssh works fine, but scp hangs after initial handshaking.
940 Workaround: activate this option and add a rule to your firewall
943 iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \\
944 -j TCPMSS --clamp-mss-to-pmtu
947 .BI "--set-mss " "value"
948 Explicitly set MSS option to specified value.
950 .B "--clamp-mss-to-pmtu"
951 Automatically clamp MSS value to (path_MTU - 40).
953 These options are mutually exclusive.
955 This is used to set the 8-bit Type of Service field in the IP header.
956 It is only valid in the
960 .BI "--set-tos " "tos"
961 You can use a numeric TOS values, or use
965 to see the list of valid TOS names.
967 This target provides userspace logging of matching packets. When this
968 target is set for a rule, the Linux kernel will multicast this packet
971 socket. One or more userspace processes may then subscribe to various
972 multicast groups and receive the packets.
973 Like LOG, this is a "non-terminating target", i.e. rule traversal
974 continues at the next rule.
976 .BI "--ulog-nlgroup " "nlgroup"
977 This specifies the netlink group (1-32) to which the packet is sent.
980 .BI "--ulog-prefix " "prefix"
981 Prefix log messages with the specified prefix; up to 32 characters
982 long, and useful for distinguishing messages in the logs.
984 .BI "--ulog-cprange " "size"
985 Number of bytes to be copied to userspace. A value of 0 always copies
986 the entire packet, regardless of its size. Default is 0.
988 .BI "--ulog-qthreshold " "size"
989 Number of packet to queue inside kernel. Setting this value to, e.g. 10
990 accumulates ten packets inside the kernel and transmits them as one
991 netlink multipart message to userspace. Default is 1 (for backwards
995 Various error messages are printed to standard error. The exit code
996 is 0 for correct functioning. Errors which appear to be caused by
997 invalid or abused command line parameters cause an exit code of 2, and
998 other errors cause an exit code of 1.
1000 Bugs? What's this? ;-)
1001 Well... the counters are not reliable on sparc64.
1002 .SH COMPATIBILITY WITH IPCHAINS
1005 is very similar to ipchains by Rusty Russell. The main difference is
1010 are only traversed for packets coming into the local host and
1011 originating from the local host respectively. Hence every packet only
1012 passes through one of the three chains (except loopback traffic, which
1013 involves both INPUT and OUTPUT chains); previously a forwarded packet
1014 would pass through all three.
1016 The other main difference is that
1018 refers to the input interface;
1020 refers to the output interface, and both are available for packets
1024 .PP The various forms of NAT have been separated out;
1026 is a pure packet filter when using the default `filter' table, with
1027 optional extension modules. This should simplify much of the previous
1028 confusion over the combination of IP masquerading and packet filtering
1029 seen previously. So the following options are handled differently:
1035 There are several other changes in iptables.
1037 .BR iptables-save (8),
1038 .BR iptables-restore (8),
1040 .BR ip6tables-save (8),
1041 .BR ip6tables-restore (8).
1043 The packet-filtering-HOWTO details iptables usage for
1044 packet filtering, the NAT-HOWTO details NAT,
1045 the netfilter-extensions-HOWTO details the extensions that are
1046 not in the standard distribution,
1047 and the netfilter-hacking-HOWTO details the netfilter internals.
1050 .BR "http://www.netfilter.org/" .
1052 Rusty Russell wrote iptables, in early consultation with Michael
1055 Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
1056 selection framework in iptables, then wrote the mangle table, the owner match,
1057 the mark stuff, and ran around doing cool stuff everywhere.
1059 James Morris wrote the TOS target, and tos match.
1061 Jozsef Kadlecsik wrote the REJECT target.
1063 Harald Welte wrote the ULOG target, TTL, DSCP, ECN matches and targets.
1065 The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Jozsef Kadlecsik,
1066 James Morris, Harald Welte and Rusty Russell.
1068 Man page written by Herve Eychenne <rv@wallfire.org>.
1069 .\" .. and did I mention that we are incredibly cool people?
1071 .\" .. witty, charming, powerful ..
1072 .\" .. and most of all, modest ..