Merge to iptables-1.3.5
[iptables.git] / iptables.8
1 .TH IPTABLES 8 "Mar 09, 2002" "" ""
2 .\"
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)
6 .\"
7 .\" ipchains page by Paul ``Rusty'' Russell March 1997
8 .\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl>
9 .\"
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.
14 .\"
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.
19 .\"
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.
23 .\"
24 .\"
25 .SH NAME
26 iptables \- administration tool for IPv4 packet filtering and NAT
27 .SH SYNOPSIS
28 .BR "iptables [-t table] -[AD] " "chain rule-specification [options]"
29 .br
30 .BR "iptables [-t table] -I " "chain [rulenum] rule-specification [options]"
31 .br
32 .BR "iptables [-t table] -R " "chain rulenum rule-specification [options]"
33 .br
34 .BR "iptables [-t table] -D " "chain rulenum [options]"
35 .br
36 .BR "iptables [-t table] -[LFZ] " "[chain] [options]"
37 .br
38 .BR "iptables [-t table] -N " "chain"
39 .br
40 .BR "iptables [-t table] -X " "[chain]"
41 .br
42 .BR "iptables [-t table] -P " "chain target [options]"
43 .br
44 .BR "iptables [-t table] -E " "old-chain-name new-chain-name"
45 .SH DESCRIPTION
46 .B Iptables
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.
51
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
55 table.
56
57 .SH TARGETS
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
62 special values 
63 .IR ACCEPT ,
64 .IR DROP ,
65 .IR QUEUE ,
66 or
67 .IR RETURN .
68 .PP
69 .I ACCEPT 
70 means to let the packet through.
71 .I DROP
72 means to drop the packet on the floor.
73 .I QUEUE
74 means to pass the packet to userspace.  (How the packet can be received
75 by a userspace process differs by the particular queue handler.  2.4.x
76 and 2.6.x kernels up to 2.6.13 include the 
77 .B
78 ip_queue
79 queue handler.  Kernels 2.6.14 and later additionally include the 
80 .B
81 nfnetlink_queue
82 queue handler.  Packets with a target of QUEUE will be sent to queue number '0'
83 in this case. Please also see the
84 .B
85 NFQUEUE
86 target as described later in this man page.)
87 .I RETURN
88 means stop traversing this chain and resume at the next rule in the
89 previous (calling) chain.  If the end of a built-in chain is reached
90 or a rule in a built-in chain with target
91 .I RETURN
92 is matched, the target specified by the chain policy determines the
93 fate of the packet.
94 .SH TABLES
95 There are currently three independent tables (which tables are present
96 at any time depends on the kernel configuration options and which
97 modules are present).
98 .TP
99 .BI "-t, --table " "table"
100 This option specifies the packet matching table which the command
101 should operate on.  If the kernel is configured with automatic module
102 loading, an attempt will be made to load the appropriate module for
103 that table if it is not already there.
104
105 The tables are as follows:
106 .RS
107 .TP .4i
108 .BR "filter" :
109 This is the default table (if no -t option is passed).  It contains
110 the built-in chains
111 .B INPUT
112 (for packets destined to local sockets),
113 .B FORWARD
114 (for packets being routed through the box), and
115 .B OUTPUT
116 (for locally-generated packets).
117 .TP
118 .BR "nat" :
119 This table is consulted when a packet that creates a new
120 connection is encountered.  It consists of three built-ins:
121 .B PREROUTING
122 (for altering packets as soon as they come in),
123 .B OUTPUT
124 (for altering locally-generated packets before routing), and
125 .B POSTROUTING
126 (for altering packets as they are about to go out).
127 .TP
128 .BR "mangle" :
129 This table is used for specialized packet alteration.  Until kernel
130 2.4.17 it had two built-in chains:
131 .B PREROUTING
132 (for altering incoming packets before routing) and
133 .B OUTPUT
134 (for altering locally-generated packets before routing).
135 Since kernel 2.4.18, three other built-in chains are also supported:
136 .B INPUT
137 (for packets coming into the box itself),
138 .B FORWARD
139 (for altering packets being routed through the box), and
140 .B POSTROUTING
141 (for altering packets as they are about to go out).
142 .TP
143 .BR "raw" :
144 This table is used mainly for configuring exemptions from connection
145 tracking in combination with the NOTRACK target.  It registers at the netfilter
146 hooks with higher priority and is thus called before ip_conntrack, or any other
147 IP tables.  It provides the following built-in chains:
148 .B PREROUTING
149 (for packets arriving via any network interface)
150 .B OUTPUT
151 (for packets generated by local processes)
152 .RE
153 .SH OPTIONS
154 The options that are recognized by
155 .B iptables
156 can be divided into several different groups.
157 .SS COMMANDS
158 These options specify the specific action to perform.  Only one of them
159 can be specified on the command line unless otherwise specified
160 below.  For all the long versions of the command and option names, you
161 need to use only enough letters to ensure that
162 .B iptables
163 can differentiate it from all other options.
164 .TP
165 .BI "-A, --append " "chain rule-specification"
166 Append one or more rules to the end of the selected chain.
167 When the source and/or destination names resolve to more than one
168 address, a rule will be added for each possible address combination.
169 .TP
170 .BI "-D, --delete " "chain rule-specification"
171 .ns
172 .TP
173 .BI "-D, --delete " "chain rulenum"
174 Delete one or more rules from the selected chain.  There are two
175 versions of this command: the rule can be specified as a number in the
176 chain (starting at 1 for the first rule) or a rule to match.
177 .TP
178 .BR "-I, --insert " "\fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP"
179 Insert one or more rules in the selected chain as the given rule
180 number.  So, if the rule number is 1, the rule or rules are inserted
181 at the head of the chain.  This is also the default if no rule number
182 is specified.
183 .TP
184 .BI "-R, --replace " "chain rulenum rule-specification"
185 Replace a rule in the selected chain.  If the source and/or
186 destination names resolve to multiple addresses, the command will
187 fail.  Rules are numbered starting at 1.
188 .TP
189 .BR "-L, --list " "[\fIchain\fP]"
190 List all rules in the selected chain.  If no chain is selected, all
191 chains are listed.  As every other iptables command, it applies to the
192 specified table (filter is the default), so NAT rules get listed by
193 .nf
194  iptables -t nat -n -L
195 .fi
196 Please note that it is often used with the
197 .B -n
198 option, in order to avoid long reverse DNS lookups.
199 It is legal to specify the
200 .B -Z
201 (zero) option as well, in which case the chain(s) will be atomically
202 listed and zeroed.  The exact output is affected by the other
203 arguments given. The exact rules are suppressed until you use
204 .nf
205  iptables -L -v
206 .fi
207 .TP
208 .BR "-F, --flush " "[\fIchain\fP]"
209 Flush the selected chain (all the chains in the table if none is given).
210 This is equivalent to deleting all the rules one by one.
211 .TP
212 .BR "-Z, --zero " "[\fIchain\fP]"
213 Zero the packet and byte counters in all chains.  It is legal to
214 specify the
215 .B "-L, --list"
216 (list) option as well, to see the counters immediately before they are
217 cleared. (See above.)
218 .TP
219 .BI "-N, --new-chain " "chain"
220 Create a new user-defined chain by the given name.  There must be no
221 target of that name already.
222 .TP
223 .BR "-X, --delete-chain " "[\fIchain\fP]"
224 Delete the optional user-defined chain specified.  There must be no references
225 to the chain.  If there are, you must delete or replace the referring rules
226 before the chain can be deleted.  The chain must be empty, i.e. not contain
227 any rules.  If no argument is given, it will attempt to delete every
228 non-builtin chain in the table.
229 .TP
230 .BI "-P, --policy " "chain target"
231 Set the policy for the chain to the given target.  See the section
232 .B TARGETS
233 for the legal targets.  Only built-in (non-user-defined) chains can have
234 policies, and neither built-in nor user-defined chains can be policy
235 targets.
236 .TP
237 .BI "-E, --rename-chain " "old-chain new-chain"
238 Rename the user specified chain to the user supplied name.  This is
239 cosmetic, and has no effect on the structure of the table.
240 .TP
241 .B -h
242 Help.
243 Give a (currently very brief) description of the command syntax.
244 .SS PARAMETERS
245 The following parameters make up a rule specification (as used in the
246 add, delete, insert, replace and append commands).
247 .TP
248 .BR "-p, --protocol " "[!] \fIprotocol\fP"
249 The protocol of the rule or of the packet to check.
250 The specified protocol can be one of
251 .IR tcp ,
252 .IR udp ,
253 .IR icmp ,
254 or
255 .IR all ,
256 or it can be a numeric value, representing one of these protocols or a
257 different one.  A protocol name from /etc/protocols is also allowed.
258 A "!" argument before the protocol inverts the
259 test.  The number zero is equivalent to
260 .IR all .
261 Protocol
262 .I all
263 will match with all protocols and is taken as default when this
264 option is omitted.
265 .TP
266 .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
267 Source specification.
268 .I Address
269 can be either a network name, a hostname (please note that specifying
270 any name to be resolved with a remote query such as DNS is a really bad idea),
271 a network IP address (with /mask), or a plain IP address.
272 The
273 .I mask
274 can be either a network mask or a plain number,
275 specifying the number of 1's at the left side of the network mask.
276 Thus, a mask of
277 .I 24
278 is equivalent to
279 .IR 255.255.255.0 .
280 A "!" argument before the address specification inverts the sense of
281 the address. The flag
282 .B --src
283 is an alias for this option.
284 .TP
285 .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
286 Destination specification. 
287 See the description of the
288 .B -s
289 (source) flag for a detailed description of the syntax.  The flag
290 .B --dst
291 is an alias for this option.
292 .TP
293 .BI "-j, --jump " "target"
294 This specifies the target of the rule; i.e., what to do if the packet
295 matches it.  The target can be a user-defined chain (other than the
296 one this rule is in), one of the special builtin targets which decide
297 the fate of the packet immediately, or an extension (see
298 .B EXTENSIONS
299 below).  If this
300 option is omitted in a rule (and
301 .B -g
302 is not used), then matching the rule will have no
303 effect on the packet's fate, but the counters on the rule will be
304 incremented.
305 .TP
306 .BI "-g, --goto " "chain"
307 This specifies that the processing should continue in a user
308 specified chain. Unlike the --jump option return will not continue
309 processing in this chain but instead in the chain that called us via
310 --jump.
311 .TP
312 .BR "-i, --in-interface " "[!] \fIname\fP"
313 Name of an interface via which a packet was received (only for
314 packets entering the 
315 .BR INPUT ,
316 .B FORWARD
317 and
318 .B PREROUTING
319 chains).  When the "!" argument is used before the interface name, the
320 sense is inverted.  If the interface name ends in a "+", then any
321 interface which begins with this name will match.  If this option is
322 omitted, any interface name will match.
323 .TP
324 .BR "-o, --out-interface " "[!] \fIname\fP"
325 Name of an interface via which a packet is going to be sent (for packets
326 entering the
327 .BR FORWARD ,
328 .B OUTPUT
329 and
330 .B POSTROUTING
331 chains).  When the "!" argument is used before the interface name, the
332 sense is inverted.  If the interface name ends in a "+", then any
333 interface which begins with this name will match.  If this option is
334 omitted, any interface name will match.
335 .TP
336 .B "[!] " "-f, --fragment"
337 This means that the rule only refers to second and further fragments
338 of fragmented packets.  Since there is no way to tell the source or
339 destination ports of such a packet (or ICMP type), such a packet will
340 not match any rules which specify them.  When the "!" argument
341 precedes the "-f" flag, the rule will only match head fragments, or
342 unfragmented packets.
343 .TP
344 .BI "-c, --set-counters " "PKTS BYTES"
345 This enables the administrator to initialize the packet and byte
346 counters of a rule (during
347 .B INSERT,
348 .B APPEND,
349 .B REPLACE
350 operations).
351 .SS "OTHER OPTIONS"
352 The following additional options can be specified:
353 .TP
354 .B "-v, --verbose"
355 Verbose output.  This option makes the list command show the interface
356 name, the rule options (if any), and the TOS masks.  The packet and
357 byte counters are also listed, with the suffix 'K', 'M' or 'G' for
358 1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
359 the
360 .B -x
361 flag to change this).
362 For appending, insertion, deletion and replacement, this causes
363 detailed information on the rule or rules to be printed.
364 .TP
365 .B "-n, --numeric"
366 Numeric output.
367 IP addresses and port numbers will be printed in numeric format.
368 By default, the program will try to display them as host names,
369 network names, or services (whenever applicable).
370 .TP
371 .B "-x, --exact"
372 Expand numbers.
373 Display the exact value of the packet and byte counters,
374 instead of only the rounded number in K's (multiples of 1000)
375 M's (multiples of 1000K) or G's (multiples of 1000M).  This option is
376 only relevant for the 
377 .B -L
378 command.
379 .TP
380 .B "--line-numbers"
381 When listing rules, add line numbers to the beginning of each rule,
382 corresponding to that rule's position in the chain.
383 .TP
384 .B "--modprobe=command"
385 When adding or inserting rules into a chain, use
386 .B command
387 to load any necessary modules (targets, match extensions, etc).
388 .SH MATCH EXTENSIONS
389 iptables can use extended packet matching modules.  These are loaded
390 in two ways: implicitly, when
391 .B -p
392 or
393 .B --protocol
394 is specified, or with the
395 .B -m
396 or
397 .B --match
398 options, followed by the matching module name; after these, various
399 extra command line options become available, depending on the specific
400 module.  You can specify multiple extended match modules in one line,
401 and you can use the
402 .B -h
403 or
404 .B --help
405 options after the module has been specified to receive help specific
406 to that module.
407
408 The following are included in the base package, and most of these can
409 be preceded by a
410 .B !
411 to invert the sense of the match.
412 .\" @MATCH@
413 .SS account
414 Account traffic for all hosts in defined network/netmask.
415
416 Features:
417
418 - long (one counter per protocol TCP/UDP/IMCP/Other) and short statistics
419
420 - one iptables rule for all hosts in network/netmask
421
422 - loading/saving counters (by reading/writting to procfs entries)
423
424 .TP
425 .BI "--aaddr " "network/netmask"
426 defines network/netmask for which make statistics.
427 .TP
428 .BI "--aname " "name"
429 defines name of list where statistics will be kept. If no is
430 specified DEFAULT will be used.
431 .TP
432 .B "--ashort"
433 table will colect only short statistics (only total counters
434 without splitting it into protocols.
435 .P
436 Example usage:
437
438 account traffic for/to 192.168.0.0/24 network into table mynetwork:
439
440 # iptables -A FORWARD -m account --aname mynetwork --aaddr 192.168.0.0/24
441
442 account traffic for/to WWW serwer for 192.168.0.0/24 network into table mywwwserver:
443
444 # iptables -A INPUT -p tcp --dport 80
445   -m account --aname mywwwserver --aaddr 192.168.0.0/24 --ashort
446
447 # iptables -A OUTPUT -p tcp --sport 80
448   -m account --aname mywwwserver --aaddr 192.168.0.0/24 --ashort
449
450 read counters:
451
452 # cat /proc/net/ipt_account/mynetwork
453 # cat /proc/net/ipt_account/mywwwserver
454
455 set counters:
456
457 # echo "ip = 192.168.0.1 packets_src = 0" > /proc/net/ipt_account/mywwserver
458
459 Webpage:
460   http://www.barbara.eu.org/~quaker/ipt_account/
461 .SS addrtype
462 This module matches packets based on their 
463 .B address type.
464 Address types are used within the kernel networking stack and categorize
465 addresses into various groups.  The exact definition of that group depends on the specific layer three protocol.
466 .TP
467 The following address types are possible:
468 .TP
469 .BI "UNSPEC"
470 an unspecified address (i.e. 0.0.0.0)
471 .BI "UNICAST"
472 an unicast address
473 .BI "LOCAL"
474 a local address
475 .BI "BROADCAST"
476 a broadcast address
477 .BI "ANYCAST"
478 an anycast packet
479 .BI "MULTICAST"
480 a multicast address
481 .BI "BLACKHOLE"
482 a blackhole address
483 .BI "UNREACHABLE"
484 an unreachable address
485 .BI "PROHIBIT"
486 a prohibited address
487 .BI "THROW"
488 FIXME
489 .BI "NAT"
490 FIXME
491 .BI "XRESOLVE"
492 FIXME
493 .TP
494 .BI "--src-type " "type"
495 Matches if the source address is of given type
496 .TP
497 .BI "--dst-type " "type"
498 Matches if the destination address is of given type
499 .SS ah
500 This module matches the SPIs in Authentication header of IPsec packets.
501 .TP
502 .BR "--ahspi " "[!] \fIspi\fP[:\fIspi\fP]"
503 .SS childlevel
504 This is an experimental module.  It matches on whether the 
505 packet is part of a master connection or one of its children (or grandchildren,
506 etc).  For instance, most packets are level 0.  FTP data transfer is level 1.
507 .TP
508 .BR "--childlevel " "[!] \fIlevel\fP"
509 .SS comment
510 Allows you to add comments (up to 256 characters) to any rule.
511 .TP
512 .BI "--comment " "comment"
513 .TP
514 Example:
515 iptables -A INPUT -s 192.168.0.0/16 -m comment --comment "A privatized IP block"
516 .SS condition
517 This matches if a specific /proc filename is '0' or '1'.
518 .TP
519 .BI "--condition " "[!] \fIfilename\fP"
520 Match on boolean value stored in /proc/net/ipt_condition/filename file
521 .SS connbytes
522 Match by how many bytes or packets a connection (or one of the two
523 flows constituting the connection) have tranferred so far, or by
524 average bytes per packet.
525
526 The counters are 64bit and are thus not expected to overflow ;)
527
528 The primary use is to detect long-lived downloads and mark them to be
529 scheduled using a lower priority band in traffic control.
530
531 The transfered bytes per connection can also be viewed through
532 /proc/net/ip_conntrack and accessed via ctnetlink
533 .TP
534 [\fB!\fR]\fB --connbytes \fIfrom\fB:\fR[\fIto\fR]
535 match packets from a connection whose packets/bytes/average packet
536 size is more than FROM and less than TO bytes/packets. if TO is
537 omitted only FROM check is done. "!" is used to match packets not
538 falling in the range.
539 .TP
540 \fB--connbytes-dir\fR [\fBoriginal\fR|\fBreply\fR|\fBboth\fR]
541 which packets to consider
542 .TP
543 \fB--connbytes-mode\fR [\fBpackets\fR|\fBbytes\fR|\fBavgpkt\fR]
544 whether to check the amount of packets, number of bytes transferred or
545 the average size (in bytes) of all packets received so far. Note that
546 when "both" is used together with "avgpkt", and data is going (mainly)
547 only in one direction (for example HTTP), the average packet size will
548 be about half of the actual data packets.
549 .TP
550 Example:
551 iptables .. -m connbytes --connbytes 10000:100000 --connbytes-dir both --connbytes-mode bytes ...
552 .SS connlimit
553 Allows you to restrict the number of parallel TCP connections to a
554 server per client IP address (or address block).
555 .TP
556 [\fB!\fR] \fB--connlimit-above \fIn\fR
557 match if the number of existing tcp connections is (not) above n
558 .TP
559 .BI "--connlimit-mask " "bits"
560 group hosts using mask
561 .P
562 Examples:
563 .TP
564 # allow 2 telnet connections per client host
565 iptables -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT
566 .TP
567 # you can also match the other way around:
568 iptables -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT
569 .TP
570 # limit the nr of parallel http requests to 16 per class C sized \
571 network (24 bit netmask)
572 iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16
573 --connlimit-mask 24 -j REJECT
574 .SS connmark
575 This module matches the netfilter mark field associated with a connection
576 (which can be set using the
577 .B CONNMARK
578 target below).
579 .TP
580 .BI "--mark " "value[/mask]"
581 Matches packets in connections with the given mark value (if a mask is
582 specified, this is logically ANDed with the mark before the
583 comparison).
584 .SS connrate
585 This module matches the current transfer rate in a connection.
586 .TP
587 .BI "--connrate " "[!] [\fIfrom\fP]:[\fIto\fP]"
588 Match against the current connection transfer rate being within 'from'
589 and 'to' bytes per second. When the "!" argument is used before the
590 range, the sense of the match is inverted.
591 .SS conntrack
592 This module, when combined with connection tracking, allows access to
593 more connection tracking information than the "state" match.
594 (this module is present only if iptables was compiled under a kernel
595 supporting this feature)
596 .TP
597 .BI "--ctstate " "state"
598 Where state is a comma separated list of the connection states to
599 match.  Possible states are
600 .B INVALID
601 meaning that the packet is associated with no known connection,
602 .B ESTABLISHED
603 meaning that the packet is associated with a connection which has seen
604 packets in both directions,
605 .B NEW
606 meaning that the packet has started a new connection, or otherwise
607 associated with a connection which has not seen packets in both
608 directions, and
609 .B RELATED
610 meaning that the packet is starting a new connection, but is
611 associated with an existing connection, such as an FTP data transfer,
612 or an ICMP error.
613 .B SNAT
614 A virtual state, matching if the original source address differs from
615 the reply destination.
616 .B DNAT
617 A virtual state, matching if the original destination differs from the
618 reply source.
619 .TP
620 .BI "--ctproto " "proto"
621 Protocol to match (by number or name)
622 .TP
623 .BI "--ctorigsrc " "[!] \fIaddress\fP[/\fImask\fP]"
624 Match against original source address
625 .TP
626 .BI "--ctorigdst " "[!] \fIaddress\fP[/\fImask\fP]"
627 Match against original destination address
628 .TP
629 .BI "--ctreplsrc " "[!] \fIaddress\fP[/\fImask\fP]"
630 Match against reply source address
631 .TP
632 .BI "--ctrepldst " "[!] \fIaddress\fB[/\fImask\fP]"
633 Match against reply destination address
634 .TP
635 .BI "--ctstatus " "[\fINONE|EXPECTED|SEEN_REPLY|ASSURED\fP][,...]"
636 Match against internal conntrack states
637 .TP
638 .BI "--ctexpire " "\fItime\fP[\fI:time\fP]"
639 Match remaining lifetime in seconds against given value
640 or range of values (inclusive)
641 .SS dccp
642 .TP
643 \fB--source-port\fR,\fB--sport \fR[\fB!\fR] \fIport\fR[\fB:\fIport\fR]
644 .TP
645 \fB--destination-port\fR,\fB--dport \fR[\fB!\fR] \fIport\fR[\fB:\fIport\fR]
646 .TP
647 \fB--dccp-types\fR [\fB!\fR] \fImask\fP
648 Match when the DCCP packet type is one of 'mask'. 'mask' is a comma-separated
649 list of packet types.  Packet types are: 
650 .BR "REQUEST RESPONSE DATA ACK DATAACK CLOSEREQ CLOSE RESET SYNC SYNCACK INVALID" .
651 .TP
652 \fB--dccp-option\fR [\fB!\fR\] \fInumber\fP
653 Match if DCP option set.
654 .SS dscp
655 This module matches the 6 bit DSCP field within the TOS field in the
656 IP header.  DSCP has superseded TOS within the IETF.
657 .TP
658 .BI "--dscp " "value"
659 Match against a numeric (decimal or hex) value [0-32].
660 .TP
661 .BI "--dscp-class " "\fIDiffServ Class\fP"
662 Match the DiffServ class. This value may be any of the
663 BE, EF, AFxx or CSx classes.  It will then be converted
664 into it's according numeric value.
665 .SS dstlimit
666 This module allows you to limit the packet per second (pps) rate on a per
667 destination IP or per destination port base.  As opposed to the `limit' match,
668 every destination ip / destination port has it's own limit.
669 .TP
670 THIS MODULE IS DEPRECATED AND HAS BEEN REPLACED BY ``hashlimit''
671 .TP
672 .BI "--dstlimit " "avg"
673 Maximum average match rate (packets per second unless followed by /sec /minute /hour /day postfixes).
674 .TP
675 .BI "--dstlimit-mode " "mode"
676 The limiting hashmode.  Is the specified limit per
677 .B dstip, dstip-dstport
678 tuple, 
679 .B srcip-dstip
680 tuple, or per
681 .B srcipdstip-dstport
682 tuple.
683 .TP
684 .BI "--dstlimit-name " "name"
685 Name for /proc/net/ipt_dstlimit/* file entry
686 .TP
687 .BI "[" "--dstlimit-burst " "burst" "]"
688 Number of packets to match in a burst.  Default: 5
689 .TP
690 .BI "[" "--dstlimit-htable-size " "size" "]"
691 Number of buckets in the hashtable
692 .TP
693 .BI "[" "--dstlimit-htable-max " "max" "]"
694 Maximum number of entries in the hashtable
695 .TP
696 .BI "[" "--dstlimit-htable-gcinterval " "interval" "]"
697 Interval between garbage collection runs of the hashtable (in miliseconds).
698 Default is 1000 (1 second).
699 .TP
700 .BI "[" "--dstlimit-htable-expire " "time"
701 After which time are idle entries expired from hashtable (in miliseconds)?
702 Default is 10000 (10 seconds).
703 .SS ecn
704 This allows you to match the ECN bits of the IPv4 and TCP header.  ECN is the Explicit Congestion Notification mechanism as specified in RFC3168
705 .TP
706 .BI "--ecn-tcp-cwr"
707 This matches if the TCP ECN CWR (Congestion Window Received) bit is set.
708 .TP
709 .BI "--ecn-tcp-ece"
710 This matches if the TCP ECN ECE (ECN Echo) bit is set.
711 .TP
712 .BI "--ecn-ip-ect " "num"
713 This matches a particular IPv4 ECT (ECN-Capable Transport). You have to specify
714 a number between `0' and `3'.
715 .SS esp
716 This module matches the SPIs in ESP header of IPsec packets.
717 .TP
718 .BR "--espspi " "[!] \fIspi\fP[:\fIspi\fP]"
719 .SS fuzzy
720 This module matches a rate limit based on a fuzzy logic controller [FLC]
721 .TP
722 .BI "--lower-limit " "number"
723 Specifies the lower limit (in packets per second).
724 .TP
725 .BI "--upper-limit " "number"
726 Specifies the upper limit (in packets per second).
727 .SS hashlimit
728 This patch adds a new match called 'hashlimit'.
729 The idea is to have something like 'limit', but either per
730 destination-ip or per (destip,destport) tuple.
731
732 It gives you the ability to express
733 .IP
734  '1000 packets per second for every host in 192.168.0.0/16'
735 .IP
736  '100 packets per second for every service of 192.168.1.1'
737 .P
738 with a single iptables rule.
739 .TP
740 .BI "--hashlimit " "rate"
741 A rate just like the limit match
742 .TP
743 .BI "--hashlimit-burst " "num"
744 Burst value, just like limit match
745 .TP
746 .BI "--hashlimit-mode " "destip | destip-destport"
747 Limit per IP or per port
748 .TP
749 .BI "--hashlimit-name " "foo"
750 The name for the /proc/net/ipt_hashlimit/foo entry
751 .TP
752 .BI "--hashlimit-htable-size " "num"
753 The number of buckets of the hash table
754 .TP
755 .BI "--hashlimit-htable-max " "num"
756 Maximum entries in the hash
757 .TP
758 .BI "--hashlimit-htable-expire " "num"
759 After how many miliseconds do hash entries expire
760 .TP
761 .BI "--hashlimit-htable-gcinterval " "num"
762 How many miliseconds between garbage collection intervals
763 .SS helper
764 This module matches packets related to a specific conntrack-helper.
765 .TP
766 .BI "--helper " "string"
767 Matches packets related to the specified conntrack-helper.
768 .RS
769 .PP
770 string can be "ftp" for packets related to a ftp-session on default port.
771 For other ports append -portnr to the value, ie. "ftp-2121".
772 .PP
773 Same rules apply for other conntrack-helpers.
774 .RE
775 .SS icmp
776 This extension is loaded if `--protocol icmp' is specified.  It
777 provides the following option:
778 .TP
779 .BR "--icmp-type " "[!] \fItypename\fP"
780 This allows specification of the ICMP type, which can be a numeric
781 ICMP type, or one of the ICMP type names shown by the command
782 .nf
783  iptables -p icmp -h
784 .fi
785 .SS iprange
786 This matches on a given arbitrary range of IPv4 addresses
787 .TP
788 .BI "[!]" "--src-range " "ip-ip"
789 Match source IP in the specified range.
790 .TP
791 .BI "[!]" "--dst-range " "ip-ip"
792 Match destination IP in the specified range.
793 .SS ipv4options
794 Match on IPv4 header options like source routing, record route,
795 timestamp and router-alert.
796 .TP
797 .B "--ssrr"
798 To match packets with the flag strict source routing.
799 .TP
800 .B "--lsrr"
801 To match packets with the flag loose source routing.
802 .TP
803 .B "--no-srr"
804 To match packets with no flag for source routing.
805 .TP
806 .B "\fR[\fB!\fR]\fB --rr"
807 To match packets with the RR flag.
808 .TP
809 .B "\fR[\fB!\fR]\fB --ts"
810 To match packets with the TS flag.
811 .TP
812 .B "\fR[\fB!\fR]\fB --ra"
813 To match packets with the router-alert option.
814 .TP
815 .B "\fR[\fB!\fR]\fB --any-opt"
816 To match a packet with at least one IP option, or no IP option
817 at all if ! is chosen.
818 .TP
819 Examples:
820 .TP
821 $ iptables -A input -m ipv4options --rr -j DROP
822 will drop packets with the record-route flag.
823 .TP
824 $ iptables -A input -m ipv4options --ts -j DROP
825 will drop packets with the timestamp flag.
826 .SS length
827 This module matches the length of a packet against a specific value
828 or range of values.
829 .TP
830 .BR "--length " "[!] \fIlength\fP[:\fIlength\fP]"
831 .SS limit
832 This module matches at a limited rate using a token bucket filter.
833 A rule using this extension will match until this limit is reached
834 (unless the `!' flag is used).  It can be used in combination with the
835 .B LOG
836 target to give limited logging, for example.
837 .TP
838 .BI "--limit " "rate"
839 Maximum average matching rate: specified as a number, with an optional
840 `/second', `/minute', `/hour', or `/day' suffix; the default is
841 3/hour.
842 .TP
843 .BI "--limit-burst " "number"
844 Maximum initial number of packets to match: this number gets
845 recharged by one every time the limit specified above is not reached,
846 up to this number; the default is 5.
847 .SS mac
848 .TP
849 .BR "--mac-source " "[!] \fIaddress\fP"
850 Match source MAC address.  It must be of the form XX:XX:XX:XX:XX:XX.
851 Note that this only makes sense for packets coming from an Ethernet device
852 and entering the
853 .BR PREROUTING ,
854 .B FORWARD
855 or
856 .B INPUT
857 chains.
858 .SS mark
859 This module matches the netfilter mark field associated with a packet
860 (which can be set using the
861 .B MARK
862 target below).
863 .TP
864 .BR "--mark " "\fIvalue\fP[/\fImask\fP]"
865 Matches packets with the given unsigned mark value (if a \fImask\fP is
866 specified, this is logically ANDed with the \fImask\fP before the
867 comparison).
868 .SS mport
869 This module matches a set of source or destination ports.  Up to 15
870 ports can be specified.  It can only be used in conjunction with
871 .B "-p tcp"
872 or
873 .BR "-p udp" .
874 .TP
875 .BR "--source-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
876 Match if the source port is one of the given ports.  The flag
877 .B --sports
878 is a convenient alias for this option.
879 .TP
880 .BR "--destination-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
881 Match if the destination port is one of the given ports.  The flag
882 .B --dports
883 is a convenient alias for this option.
884 .TP
885 .BR "--ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]"
886 Match if the both the source and destination ports are equal to each
887 other and to one of the given ports.
888 .SS multiport
889 This module matches a set of source or destination ports.  Up to 15
890 ports can be specified.  A port range (port:port) counts as two
891 ports.  It can only be used in conjunction with
892 .B "-p tcp"
893 or
894 .BR "-p udp" .
895 .TP
896 .BR "--source-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
897 Match if the source port is one of the given ports.  The flag
898 .B --sports
899 is a convenient alias for this option.
900 .TP
901 .BR "--destination-ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
902 Match if the destination port is one of the given ports.  The flag
903 .B --dports
904 is a convenient alias for this option.
905 .TP
906 .BR "--ports " "\fI[!] port\fP[,\fIport\fP[,\fIport:port\fP...]]"
907 Match if either the source or destination ports are equal to one of
908 the given ports.
909 .SS nth
910 This module matches every `n'th packet
911 .TP
912 .BI "--every " "value"
913 Match every `value' packet
914 .TP
915 .BI "[" "--counter " "num" "]"
916 Use internal counter number `num'.  Default is `0'.
917 .TP
918 .BI "[" "--start " "num" "]"
919 Initialize the counter at the number `num' insetad of `0'.  Most between `0'
920 and `value'-1.
921 .TP
922 .BI "[" "--packet " "num" "]"
923 Match on `num' packet.  Most be between `0' and `value'-1.
924 .SS osf
925 The idea of passive OS fingerprint matching exists for quite a long time,
926 but was created as extension fo OpenBSD pf only some weeks ago.
927 Original idea was lurked in some OpenBSD mailing list (thanks
928 grange@open...) and than adopted for Linux netfilter in form of this code.
929
930 Original fingerprint table was created by Michal Zalewski <lcamtuf@coredump.cx>.
931
932 This module compares some data(WS, MSS, options and it's order, ttl,
933 df and others) from first SYN packet (actually from packets with SYN
934 bit set) with dynamically loaded OS fingerprints.
935 .TP
936 .B "--log 1/0" 
937 If present, OSF will log determined genres even if they don't match
938 desired one.    
939 0 - log all determined entries, 
940 1 - only first one.
941
942 In syslog you find something like this:
943 .IP
944 ipt_osf: Windows [2000:SP3:Windows XP Pro SP1, 2000 SP3]: 11.22.33.55:4024 -> 11.22.33.44:139
945 .IP
946 ipt_osf: Unknown: 16384:106:1:48:020405B401010402 44.33.22.11:1239 -> 11.22.33.44:80
947 .TP
948 .B "--smart"
949 if present, OSF will use some smartness to determine remote OS.
950 OSF will use initial TTL only if source of connection is in our local network.
951 .TP
952 .B "--netlink"
953 If present, OSF will log all events also through netlink NETLINK_NFLOG groupt 1.
954 .TP
955 .BI "--genre " "[!] string"
956 Match a OS genre by passive fingerprinting
957 .P
958 Example:
959
960 #iptables -I INPUT -j ACCEPT -p tcp -m osf --genre Linux --log 1 --smart
961
962 NOTE: -p tcp is obviously required as it is a TCP match.
963
964 Fingerprints can be loaded and read through /proc/sys/net/ipv4/osf file.
965 One can flush all fingerprints with following command:
966 .IP
967 echo -en FLUSH > /proc/sys/net/ipv4/osf
968 .P
969 Only one fingerprint per open/write/close.
970
971 Fingerprints can be downloaded from http://www.openbsd.org/cgi-bin/cvsweb/src/etc/pf.os
972 .SS owner
973 This module attempts to match various characteristics of the packet
974 creator, for locally-generated packets.  It is only valid in the
975 .B OUTPUT
976 chain, and even this some packets (such as ICMP ping responses) may
977 have no owner, and hence never match.
978 .TP
979 .BI "--uid-owner " "userid"
980 Matches if the packet was created by a process with the given
981 effective user id.
982 .TP
983 .BI "--gid-owner " "groupid"
984 Matches if the packet was created by a process with the given
985 effective group id.
986 .TP
987 .BI "--pid-owner " "processid"
988 Matches if the packet was created by a process with the given
989 process id.
990 .TP
991 .BI "--sid-owner " "sessionid"
992 Matches if the packet was created by a process in the given session
993 group.
994 .TP
995 .BI "--cmd-owner " "name"
996 Matches if the packet was created by a process with the given command name.
997 (this option is present only if iptables was compiled under a kernel
998 supporting this feature)
999 .TP
1000 .B NOTE: pid, sid and command matching are broken on SMP
1001 .SS physdev
1002 This module matches on the bridge port input and output devices enslaved
1003 to a bridge device. This module is a part of the infrastructure that enables
1004 a transparent bridging IP firewall and is only useful for kernel versions
1005 above version 2.5.44.
1006 .TP
1007 .BR --physdev-in " [!] \fIname\fP"
1008 Name of a bridge port via which a packet is received (only for
1009 packets entering the
1010 .BR INPUT ,
1011 .B FORWARD
1012 and
1013 .B PREROUTING
1014 chains). If the interface name ends in a "+", then any
1015 interface which begins with this name will match. If the packet didn't arrive
1016 through a bridge device, this packet won't match this option, unless '!' is used.
1017 .TP
1018 .BR --physdev-out " [!] \fIname\fP"
1019 Name of a bridge port via which a packet is going to be sent (for packets
1020 entering the
1021 .BR FORWARD ,
1022 .B OUTPUT
1023 and
1024 .B POSTROUTING
1025 chains).  If the interface name ends in a "+", then any
1026 interface which begins with this name will match. Note that in the
1027 .BR nat " and " mangle
1028 .B OUTPUT
1029 chains one cannot match on the bridge output port, however one can in the
1030 .B "filter OUTPUT"
1031 chain. If the packet won't leave by a bridge device or it is yet unknown what
1032 the output device will be, then the packet won't match this option, unless
1033 '!' is used.
1034 .TP
1035 .RB "[!] " --physdev-is-in
1036 Matches if the packet has entered through a bridge interface.
1037 .TP
1038 .RB "[!] " --physdev-is-out
1039 Matches if the packet will leave through a bridge interface.
1040 .TP
1041 .RB "[!] " --physdev-is-bridged
1042 Matches if the packet is being bridged and therefore is not being routed.
1043 This is only useful in the FORWARD and POSTROUTING chains.
1044 .SS pkttype
1045 This module matches the link-layer packet type.
1046 .TP
1047 .BI "--pkt-type " "[\fIunicast\fP|\fIbroadcast\fP|\fImulticast\fP]"
1048 .SS policy
1049 This modules matches the policy used by IPsec for handling a packet.
1050 .TP
1051 .BI "--dir " "in|out"
1052 Used to select whether to match the policy used for decapsulation or the
1053 policy that will be used for encapsulation.
1054 .B in
1055 is valid in the
1056 .B PREROUTING, INPUT and FORWARD
1057 chains,
1058 .B out
1059 is valid in the
1060 .B POSTROUTING, OUTPUT and FORWARD
1061 chains.
1062 .TP
1063 .BI "--pol " "none|ipsec"
1064 Matches if the packet is subject to IPsec processing.
1065 .TP
1066 .BI "--strict"
1067 Selects whether to match the exact policy or match if any rule of
1068 the policy matches the given policy.
1069 .TP
1070 .BI "--reqid " "id"
1071 Matches the reqid of the policy rule. The reqid can be specified with
1072 .B setkey(8)
1073 using
1074 .B unique:id
1075 as level.
1076 .TP
1077 .BI "--spi " "spi"
1078 Matches the SPI of the SA.
1079 .TP
1080 .BI "--proto " "ah|esp|ipcomp"
1081 Matches the encapsulation protocol.
1082 .TP
1083 .BI "--mode " "tunnel|transport"
1084 Matches the encapsulation mode.
1085 .TP
1086 .BI "--tunnel-src " "addr[/mask]"
1087 Matches the source end-point address of a tunnel mode SA.
1088 Only valid with --mode tunnel.
1089 .TP
1090 .BI "--tunnel-dst " "addr[/mask]"
1091 Matches the destination end-point address of a tunnel mode SA.
1092 Only valid with --mode tunnel.
1093 .TP
1094 .BI "--next"
1095 Start the next element in the policy specification. Can only be used with
1096 --strict
1097 .SS psd
1098 Attempt to detect TCP and UDP port scans. This match was derived from
1099 Solar Designer's scanlogd.
1100 .TP
1101 .BI "--psd-weight-threshold " "threshold"
1102 Total weight of the latest TCP/UDP packets with different
1103 destination ports coming from the same host to be treated as port
1104 scan sequence.
1105 .TP
1106 .BI "--psd-delay-threshold " "delay"
1107 Delay (in hundredths of second) for the packets with different
1108 destination ports coming from the same host to be treated as
1109 possible port scan subsequence.
1110 .TP
1111 .BI "--psd-lo-ports-weight " "weight"
1112 Weight of the packet with privileged (<=1024) destination port.
1113 .TP
1114 .BI "--psd-hi-ports-weight " "weight"
1115 Weight of the packet with non-priviliged destination port.
1116 .SS quota
1117 Implements network quotas by decrementing a byte counter with each
1118 packet.
1119 .TP
1120 .BI "--quota " "bytes"
1121 The quota in bytes.
1122 .P
1123 KNOWN BUGS: this does not work on SMP systems.
1124 .SS random
1125 This module randomly matches a certain percentage of all packets.
1126 .TP
1127 .BI "--average " "percent"
1128 Matches the given percentage.  If omitted, a probability of 50% is set. 
1129 .SS realm
1130 This matches the routing realm.  Routing realms are used in complex routing
1131 setups involving dynamic routing protocols like BGP.
1132 .TP
1133 .BI "--realm " "[!]" "value[/mask]"
1134 Matches a given realm number (and optionally mask).
1135 .SS recent
1136 Allows you to dynamically create a list of IP addresses and then match
1137 against that list in a few different ways.
1138
1139 For example, you can create a `badguy' list out of people attempting
1140 to connect to port 139 on your firewall and then DROP all future
1141 packets from them without considering them.
1142 .TP
1143 .BI "--name " "name"
1144 Specify the list to use for the commands. If no name is given then 'DEFAULT'
1145 will be used.
1146 .TP
1147 [\fB!\fR] \fB--set\fR
1148 This will add the source address of the packet to the list. If the
1149 source address is already in the list, this will update the existing
1150 entry. This will always return success (or failure if `!' is passed
1151 in).
1152 .TP
1153 [\fB!\fR] \fB--rcheck\fR
1154 Check if the source address of the packet is currently in
1155 the list.
1156 .TP
1157 [\fB!\fR] \fB--update\fR
1158 Like \fB--rcheck\fR, except it will update the "last seen" timestamp if it
1159 matches.
1160 .TP
1161 [\fB!\fR] \fB--remove\fR
1162 Check if the source address of the packet is currently in the list and
1163 if so that address will be removed from the list and the rule will
1164 return true. If the address is not found, false is returned.
1165 .TP
1166 [\fB!\fR] \fB--seconds \fIseconds\fR
1167 This option must be used in conjunction with one of \fB--rcheck\fR or
1168 \fB--update\fR. When used, this will narrow the match to only happen
1169 when the address is in the list and was seen within the last given
1170 number of seconds.
1171 .TP
1172 [\fB!\fR] \fB--hitcount \fIhits\fR
1173 This option must be used in conjunction with one of \fB--rcheck\fR or
1174 \fB--update\fR. When used, this will narrow the match to only happen
1175 when the address is in the list and packets had been received greater
1176 than or equal to the given value. This option may be used along with
1177 \fB--seconds\fR to create an even narrower match requiring a certain
1178 number of hits within a specific time frame.
1179 .TP
1180 \fB--rttl\fR
1181 This option must be used in conjunction with one of \fB--rcheck\fR or
1182 \fB--update\fR. When used, this will narrow the match to only happen
1183 when the address is in the list and the TTL of the current packet
1184 matches that of the packet which hit the \fB--set\fR rule. This may be
1185 useful if you have problems with people faking their source address in
1186 order to DoS you via this module by disallowing others access to your
1187 site by sending bogus packets to you.
1188 .P
1189 Examples:
1190 .IP
1191 # iptables -A FORWARD -m recent --name badguy --rcheck --seconds 60 -j DROP
1192
1193 # iptables -A FORWARD -p tcp -i eth0 --dport 139 -m recent --name badguy --set -j DROP
1194 .P
1195 Official website (http://snowman.net/projects/ipt_recent/) also has
1196 some examples of usage.
1197
1198 /proc/net/ipt_recent/* are the current lists of addresses and information 
1199 about each entry of each list.
1200
1201 Each file in /proc/net/ipt_recent/ can be read from to see the current list
1202 or written two using the following commands to modify the list:
1203 .TP
1204 echo xx.xx.xx.xx > /proc/net/ipt_recent/DEFAULT
1205 to Add to the DEFAULT list
1206 .TP
1207 echo -xx.xx.xx.xx > /proc/net/ipt_recent/DEFAULT
1208 to Remove from the DEFAULT list
1209 .TP
1210 echo clear > /proc/net/ipt_recent/DEFAULT
1211 to empty the DEFAULT list.
1212 .P
1213 The module itself accepts parameters, defaults shown:
1214 .TP
1215 .BI "ip_list_tot=" "100"
1216 Number of addresses remembered per table
1217 .TP
1218 .BI "ip_pkt_list_tot=" "20"
1219 Number of packets per address remembered
1220 .TP
1221 .BI "ip_list_hash_size=" "0"
1222 Hash table size. 0 means to calculate it based on ip_list_tot, default: 512
1223 .TP
1224 .BI "ip_list_perms=" "0644"
1225 Permissions for /proc/net/ipt_recent/* files
1226 .TP
1227 .BI "debug=" "0"
1228 Set to 1 to get lots of debugging info
1229 .SS sctp
1230 .TP
1231 \fB--source-port\fR,\fB--sport \fR[\fB!\fR] \fIport\fR[\fB:\fIport\fR]
1232 .TP
1233 \fB--destination-port\fR,\fB--dport \fR[\fB!\fR] \fIport\fR[\fB:\fIport\fR]
1234 .TP
1235 \fB--chunk-types\fR [\fB!\fR] \fBall\fR|\fBany\fR|\fBonly \fIchunktype\fR[\fB:\fIflags\fR] [...]
1236 The flag letter in upper case indicates that the flag is to match if set,
1237 in the lower case indicates to match if unset.
1238
1239 Chunk types: DATA INIT INIT_ACK SACK HEARTBEAT HEARTBEAT_ACK ABORT SHUTDOWN SHUTDOWN_ACK ERROR COOKIE_ECHO COOKIE_ACK ECN_ECNE ECN_CWR SHUTDOWN_COMPLETE ASCONF ASCONF_ACK
1240
1241 chunk type            available flags      
1242 .br
1243 DATA                  U B E u b e         
1244 .br
1245 ABORT                 T t                 
1246 .br
1247 SHUTDOWN_COMPLETE     T t                 
1248
1249 (lowercase means flag should be "off", uppercase means "on")
1250 .P
1251 Examples:
1252
1253 iptables -A INPUT -p sctp --dport 80 -j DROP
1254
1255 iptables -A INPUT -p sctp --chunk-types any DATA,INIT -j DROP
1256
1257 iptables -A INPUT -p sctp --chunk-types any DATA:Be -j ACCEPT
1258 .SS set
1259 This modules macthes IP sets which can be defined by ipset(8).
1260 .TP
1261 .BR "--set " "setname flag[,flag...]"
1262 where flags are
1263 .BR "src"
1264 and/or
1265 .BR "dst" 
1266 and there can be no more than six of them. Hence the command
1267 .nf
1268  iptables -A FORWARD -m set --set test src,dst
1269 .fi
1270 will match packets, for which (depending on the type of the set) the source
1271 address or port number of the packet can be found in the specified set. If 
1272 there is a binding belonging to the mached set element or there is a default 
1273 binding for the given set, then the rule will match the packet only if 
1274 additionally (depending on the type of the set) the destination address or 
1275 port number of the packet can be found in the set according to the binding.
1276 .SS state
1277 This module, when combined with connection tracking, allows access to
1278 the connection tracking state for this packet.
1279 .TP
1280 .BI "--state " "state"
1281 Where state is a comma separated list of the connection states to
1282 match.  Possible states are
1283 .B INVALID
1284 meaning that the packet could not be identified for some reason which
1285 includes running out of memory and ICMP errors which don't correspond to any
1286 known connection,
1287 .B ESTABLISHED
1288 meaning that the packet is associated with a connection which has seen
1289 packets in both directions,
1290 .B NEW
1291 meaning that the packet has started a new connection, or otherwise
1292 associated with a connection which has not seen packets in both
1293 directions, and
1294 .B RELATED
1295 meaning that the packet is starting a new connection, but is
1296 associated with an existing connection, such as an FTP data transfer,
1297 or an ICMP error.
1298 .SS string
1299 This modules matches a given string by using some pattern matching strategy. It requires a linux kernel >= 2.6.14.
1300 .TP
1301 .BI "--algo  " "bm|kmp"
1302 Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morris)
1303 .TP
1304 .BI "--from " "offset"
1305 Set the offset from which it starts looking for any matching. If not passed, default is 0.
1306 .TP
1307 .BI "--to " "offset"
1308 Set the offset from which it starts looking for any matching. If not passed, default is the packet size.
1309 .TP
1310 .BI "--string " "pattern"
1311 Matches the given pattern.
1312 .BI "--hex-string " "pattern"
1313 Matches the given pattern in hex notation.
1314 .SS tcp
1315 These extensions are loaded if `--protocol tcp' is specified. It
1316 provides the following options:
1317 .TP
1318 .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]"
1319 Source port or port range specification. This can either be a service
1320 name or a port number. An inclusive range can also be specified,
1321 using the format
1322 .IR port : port .
1323 If the first port is omitted, "0" is assumed; if the last is omitted,
1324 "65535" is assumed.
1325 If the second port greater then the first they will be swapped.
1326 The flag
1327 .B --sport
1328 is a convenient alias for this option.
1329 .TP
1330 .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]"
1331 Destination port or port range specification.  The flag
1332 .B --dport
1333 is a convenient alias for this option.
1334 .TP
1335 .BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP"
1336 Match when the TCP flags are as specified.  The first argument is the
1337 flags which we should examine, written as a comma-separated list, and
1338 the second argument is a comma-separated list of flags which must be
1339 set.  Flags are:
1340 .BR "SYN ACK FIN RST URG PSH ALL NONE" .
1341 Hence the command
1342 .nf
1343  iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
1344 .fi
1345 will only match packets with the SYN flag set, and the ACK, FIN and
1346 RST flags unset.
1347 .TP
1348 .B "[!] --syn"
1349 Only match TCP packets with the SYN bit set and the ACK,RST and FIN bits
1350 cleared.  Such packets are used to request TCP connection initiation;
1351 for example, blocking such packets coming in an interface will prevent
1352 incoming TCP connections, but outgoing TCP connections will be
1353 unaffected.
1354 It is equivalent to \fB--tcp-flags SYN,RST,ACK,FIN SYN\fP.
1355 If the "!" flag precedes the "--syn", the sense of the
1356 option is inverted.
1357 .TP
1358 .BR "--tcp-option " "[!] \fInumber\fP"
1359 Match if TCP option set.
1360 .TP
1361 .BR "--mss " "\fIvalue\fP[:\fIvalue\fP]"
1362 Match TCP SYN or SYN/ACK packets with the specified MSS value (or range),
1363 which control the maximum packet size for that connection.
1364 .SS tcpmss
1365 This matches the TCP MSS (maximum segment size) field of the TCP header.  You can only use this on TCP SYN or SYN/ACK packets, since the MSS is only negotiated during the TCP handshake at connection startup time.
1366 .TP
1367 .BI "[!] "--mss " "value[:value]"
1368 Match a given TCP MSS value or range.
1369 .SS time
1370 This matches if the packet arrival time/date is within a given range. All options are facultative.
1371 .TP
1372 .BI " --timestart " "value"
1373 Match only if it is after `value' (Inclusive, format: HH:MM ; default 00:00).
1374 .TP
1375 .BI "--timestop  " "value"
1376 Match only if it is before `value' (Inclusive, format: HH:MM ; default 23:59).
1377 .TP
1378 .BI "--days " "listofdays"
1379 Match only if today is one of the given days. (format: Mon,Tue,Wed,Thu,Fri,Sat,Sun ; default everyday)
1380 .TP
1381 .BI "--datestart " "date"
1382 Match only if it is after `date' (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]] ; h,m,s start from 0 ; default to 1970)
1383 .TP
1384 .BI "--datestop " "date"
1385 Match only if it is before `date' (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]] ; h,m,s start from 0 ; default to 2037)
1386 .SS tos
1387 This module matches the 8 bits of Type of Service field in the IP
1388 header (ie. including the precedence bits).
1389 .TP
1390 .BI "--tos " "tos"
1391 The argument is either a standard name, (use
1392 .br
1393  iptables -m tos -h
1394 .br
1395 to see the list), or a numeric value to match.
1396 .SS ttl
1397 This module matches the time to live field in the IP header.
1398 .TP
1399 .BI "--ttl-eq " "ttl"
1400 Matches the given TTL value.
1401 .TP
1402 .BI "--ttl-gt " "ttl"
1403 Matches if TTL is greater than the given TTL value.
1404 .TP
1405 .BI "--ttl-lt " "ttl"
1406 Matches if TTL is less than the given TTL value.
1407 .SS u32
1408 U32 allows you to extract quantities of up to 4 bytes from a packet,
1409 AND them with specified masks, shift them by specified amounts and
1410 test whether the results are in any of a set of specified ranges.
1411 The specification of what to extract is general enough to skip over
1412 headers with lengths stored in the packet, as in IP or TCP header
1413 lengths.
1414
1415 Details and examples are in the kernel module source.
1416 .SS udp
1417 These extensions are loaded if `--protocol udp' is specified.  It
1418 provides the following options:
1419 .TP
1420 .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]"
1421 Source port or port range specification.
1422 See the description of the
1423 .B --source-port
1424 option of the TCP extension for details.
1425 .TP
1426 .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]"
1427 Destination port or port range specification.
1428 See the description of the
1429 .B --destination-port
1430 option of the TCP extension for details.
1431 .SS unclean
1432 This module takes no options, but attempts to match packets which seem
1433 malformed or unusual.  This is regarded as experimental.
1434 .SH TARGET EXTENSIONS
1435 iptables can use extended target modules: the following are included
1436 in the standard distribution.
1437 .\" @TARGET@
1438 .SS BALANCE
1439 This allows you to DNAT connections in a round-robin way over a given range of destination addresses.
1440 .TP
1441 .BI "--to-destination " "ipaddr-ipaddr"
1442 Address range to round-robin over.
1443 .SS CLASSIFY
1444 This module allows you to set the skb->priority value (and thus classify the packet into a specific CBQ class).
1445 .TP
1446 .BI "--set-class " "MAJOR:MINOR"
1447 Set the major and minor class value.
1448 .SS CLUSTERIP
1449 This module allows you to configure a simple cluster of nodes that share
1450 a certain IP and MAC address without an explicit load balancer in front of
1451 them.  Connections are statically distributed between the nodes in this
1452 cluster.
1453 .TP
1454 .BI "--new "
1455 Create a new ClusterIP.  You always have to set this on the first rule
1456 for a given ClusterIP.
1457 .TP
1458 .BI "--hashmode " "mode"
1459 Specify the hashing mode.  Has to be one of
1460 .B sourceip, sourceip-sourceport, sourceip-sourceport-destport
1461 .TP
1462 .BI "--clustermac " "mac"
1463 Specify the ClusterIP MAC address.  Has to be a link-layer multicast address
1464 .TP
1465 .BI "--total-nodes " "num"
1466 Number of total nodes within this cluster.
1467 .TP
1468 .BI "--local-node " "num"
1469 Local node number within this cluster.
1470 .TP
1471 .BI "--hash-init " "rnd"
1472 Specify the random seed used for hash initialization.
1473 .SS CONNMARK
1474 This module sets the netfilter mark value associated with a connection
1475 .TP
1476 .B --set-mark mark[/mask]
1477 Set connection mark. If a mask is specified then only those bits set in the
1478 mask is modified.
1479 .TP
1480 .B --save-mark [--mask mask]
1481 Copy the netfilter packet mark value to the connection mark. If a mask
1482 is specified then only those bits are copied.
1483 .TP
1484 .B --restore-mark [--mask mask]
1485 Copy the connection mark value to the packet. If a mask is specified
1486 then only those bits are copied. This is only valid in the
1487 .B mangle
1488 table.
1489 .SS DNAT
1490 This target is only valid in the
1491 .B nat
1492 table, in the
1493 .B PREROUTING
1494 and
1495 .B OUTPUT
1496 chains, and user-defined chains which are only called from those
1497 chains.  It specifies that the destination address of the packet
1498 should be modified (and all future packets in this connection will
1499 also be mangled), and rules should cease being examined.  It takes one
1500 type of option:
1501 .TP
1502 .BR "--to-destination " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]"
1503 which can specify a single new destination IP address, an inclusive
1504 range of IP addresses, and optionally, a port range (which is only
1505 valid if the rule also specifies
1506 .B "-p tcp"
1507 or
1508 .BR "-p udp" ).
1509 If no port range is specified, then the destination port will never be
1510 modified.
1511 .RS
1512 .PP
1513 In Kernels up to 2.6.10 you can add several --to-destination options.  For
1514 those kernels, if you specify more than one destination address, either via an
1515 address range or multiple --to-destination options, a simple round-robin (one
1516 after another in cycle) load balancing takes place between these addresses.
1517 Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to multiple ranges
1518 anymore.
1519
1520 .SS DSCP
1521 This target allows to alter the value of the DSCP bits within the TOS
1522 header of the IPv4 packet.  As this manipulates a packet, it can only
1523 be used in the mangle table.
1524 .TP
1525 .BI "--set-dscp " "value"
1526 Set the DSCP field to a numerical value (can be decimal or hex)
1527 .TP
1528 .BI "--set-dscp-class " "class"
1529 Set the DSCP field to a DiffServ class.
1530 .SS ECN
1531 This target allows to selectively work around known ECN blackholes.
1532 It can only be used in the mangle table.
1533 .TP
1534 .BI "--ecn-tcp-remove"
1535 Remove all ECN bits from the TCP header.  Of course, it can only be used
1536 in conjunction with
1537 .BR "-p tcp" .
1538 .SS IPMARK
1539 Allows you to mark a received packet basing on its IP address. This
1540 can replace many mangle/mark entries with only one, if you use
1541 firewall based classifier.
1542
1543 This target is to be used inside the mangle table, in the PREROUTING,
1544 POSTROUTING or FORWARD hooks.
1545 .TP
1546 .BI "--addr " "src/dst"
1547 Use source or destination IP address.
1548 .TP
1549 .BI "--and-mask " "mask"
1550 Perform bitwise `and' on the IP address and this mask.
1551 .TP
1552 .BI "--or-mask " "mask"
1553 Perform bitwise `or' on the IP address and this mask.
1554 .P
1555 The order of IP address bytes is reversed to meet "human order of bytes":
1556 192.168.0.1 is 0xc0a80001. At first the `and' operation is performed, then
1557 `or'.
1558
1559 Examples:
1560
1561 We create a queue for each user, the queue number is adequate
1562 to the IP address of the user, e.g.: all packets going to/from 192.168.5.2
1563 are directed to 1:0502 queue, 192.168.5.12 -> 1:050c etc.
1564
1565 We have one classifier rule:
1566 .IP
1567 tc filter add dev eth3 parent 1:0 protocol ip fw
1568 .P
1569 Earlier we had many rules just like below:
1570 .IP
1571 iptables -t mangle -A POSTROUTING -o eth3 -d 192.168.5.2 -j MARK
1572 --set-mark 0x10502
1573 .IP
1574 iptables -t mangle -A POSTROUTING -o eth3 -d 192.168.5.3 -j MARK
1575 --set-mark 0x10503
1576 .P
1577 Using IPMARK target we can replace all the mangle/mark rules with only one:
1578 .IP
1579 iptables -t mangle -A POSTROUTING -o eth3 -j IPMARK --addr=dst
1580 --and-mask=0xffff --or-mask=0x10000
1581 .P
1582 On the routers with hundreds of users there should be significant load
1583 decrease (e.g. twice).
1584 .SS IPV4OPTSSTRIP
1585 Strip all the IP options from a packet.
1586
1587 The target doesn't take any option, and therefore is extremly easy to use :
1588
1589 # iptables -t mangle -A PREROUTING -j IPV4OPTSSTRIP
1590 .SS LOG
1591 Turn on kernel logging of matching packets.  When this option is set
1592 for a rule, the Linux kernel will print some information on all
1593 matching packets (like most IP header fields) via the kernel log
1594 (where it can be read with
1595 .I dmesg
1596 or 
1597 .IR syslogd (8)).
1598 This is a "non-terminating target", i.e. rule traversal continues at
1599 the next rule.  So if you want to LOG the packets you refuse, use two
1600 separate rules with the same matching criteria, first using target LOG
1601 then DROP (or REJECT).
1602 .TP
1603 .BI "--log-level " "level"
1604 Level of logging (numeric or see \fIsyslog.conf\fP(5)).
1605 .TP
1606 .BI "--log-prefix " "prefix"
1607 Prefix log messages with the specified prefix; up to 29 letters long,
1608 and useful for distinguishing messages in the logs.
1609 .TP
1610 .B --log-tcp-sequence
1611 Log TCP sequence numbers. This is a security risk if the log is
1612 readable by users.
1613 .TP
1614 .B --log-tcp-options
1615 Log options from the TCP packet header.
1616 .TP
1617 .B --log-ip-options
1618 Log options from the IP packet header.
1619 .TP
1620 .B --log-uid
1621 Log the userid of the process which generated the packet.
1622 .SS MARK
1623 This is used to set the netfilter mark value associated with the
1624 packet.  It is only valid in the
1625 .B mangle
1626 table.  It can for example be used in conjunction with iproute2.
1627 .TP
1628 .BI "--set-mark " "mark"
1629 .SS MASQUERADE
1630 This target is only valid in the
1631 .B nat
1632 table, in the
1633 .B POSTROUTING
1634 chain.  It should only be used with dynamically assigned IP (dialup)
1635 connections: if you have a static IP address, you should use the SNAT
1636 target.  Masquerading is equivalent to specifying a mapping to the IP
1637 address of the interface the packet is going out, but also has the
1638 effect that connections are
1639 .I forgotten
1640 when the interface goes down.  This is the correct behavior when the
1641 next dialup is unlikely to have the same interface address (and hence
1642 any established connections are lost anyway).  It takes one option:
1643 .TP
1644 .BR "--to-ports " "\fIport\fP[-\fIport\fP]"
1645 This specifies a range of source ports to use, overriding the default
1646 .B SNAT
1647 source port-selection heuristics (see above).  This is only valid
1648 if the rule also specifies
1649 .B "-p tcp"
1650 or
1651 .BR "-p udp" .
1652 .SS MIRROR
1653 This is an experimental demonstration target which inverts the source
1654 and destination fields in the IP header and retransmits the packet.
1655 It is only valid in the
1656 .BR INPUT ,
1657 .B FORWARD
1658 and
1659 .B PREROUTING
1660 chains, and user-defined chains which are only called from those
1661 chains.  Note that the outgoing packets are
1662 .B NOT
1663 seen by any packet filtering chains, connection tracking or NAT, to
1664 avoid loops and other problems.
1665 .SS NETMAP
1666 This target allows you to statically map a whole network of addresses onto
1667 another network of addresses.  It can only be used from rules in the
1668 .B nat
1669 table.
1670 .TP
1671 .BI "--to "  "address[/mask]"
1672 Network address to map to.  The resulting address will be constructed in the
1673 following way: All 'one' bits in the mask are filled in from the new `address'.
1674 All bits that are zero in the mask are filled in from the original address.
1675 .SS NFQUEUE
1676 This target is an extension of the QUEUE target. As opposed to QUEUE, it allows
1677 you to put a packet into any specific queue, identified by its 16-bit queue
1678 number.  
1679 .TP
1680 .BR "--queue-num " "\fIvalue"
1681 This specifies the QUEUE number to use. Valud queue numbers are 0 to 65535. The default value is 0.
1682 .TP
1683 It can only be used with Kernel versions 2.6.14 or later, since it requires
1684 the
1685 .B
1686 nfnetlink_queue
1687 kernel support.
1688 .SS NOTRACK
1689 This target disables connection tracking for all packets matching that rule.
1690 .TP
1691 It can only be used in the
1692 .B raw
1693 table.
1694 .SS REDIRECT
1695 This target is only valid in the
1696 .B nat
1697 table, in the
1698 .B PREROUTING
1699 and
1700 .B OUTPUT
1701 chains, and user-defined chains which are only called from those
1702 chains.  It redirects the packet to the machine itself by changing the
1703 destination IP to the primary address of the incoming interface
1704 (locally-generated packets are mapped to the 127.0.0.1 address).  It
1705 takes one option:
1706 .TP
1707 .BR "--to-ports " "\fIport\fP[-\fIport\fP]"
1708 This specifies a destination port or range of ports to use: without
1709 this, the destination port is never altered.  This is only valid
1710 if the rule also specifies
1711 .B "-p tcp"
1712 or
1713 .BR "-p udp" .
1714 .SS REJECT
1715 This is used to send back an error packet in response to the matched
1716 packet: otherwise it is equivalent to
1717 .B DROP
1718 so it is a terminating TARGET, ending rule traversal.
1719 This target is only valid in the
1720 .BR INPUT ,
1721 .B FORWARD
1722 and
1723 .B OUTPUT
1724 chains, and user-defined chains which are only called from those
1725 chains.  The following option controls the nature of the error packet
1726 returned:
1727 .TP
1728 .BI "--reject-with " "type"
1729 The type given can be
1730 .nf
1731 .B " icmp-net-unreachable"
1732 .B " icmp-host-unreachable"
1733 .B " icmp-port-unreachable"
1734 .B " icmp-proto-unreachable"
1735 .B " icmp-net-prohibited"
1736 .B " icmp-host-prohibited or"
1737 .B " icmp-admin-prohibited (*)"
1738 .fi
1739 which return the appropriate ICMP error message (\fBport-unreachable\fP is
1740 the default).  The option
1741 .B tcp-reset
1742 can be used on rules which only match the TCP protocol: this causes a
1743 TCP RST packet to be sent back.  This is mainly useful for blocking 
1744 .I ident
1745 (113/tcp) probes which frequently occur when sending mail to broken mail
1746 hosts (which won't accept your mail otherwise).
1747 .TP
1748 (*) Using icmp-admin-prohibited with kernels that do not support it will result in a plain DROP instead of REJECT
1749 .SS ROUTE
1750 This is used to explicitly override the core network stack's routing decision.
1751 .B mangle
1752 table.
1753 .TP
1754 .BI "--oif " "ifname"
1755 Route the packet through `ifname' network interface
1756 .TP
1757 .BI "--iif " "ifname"
1758 Change the packet's incoming interface to `ifname'
1759 .TP
1760 .BI "--gw " "IP_address"
1761 Route the packet via this gateway
1762 .TP
1763 .BI "--continue "
1764 Behave like a non-terminating target and continue traversing the rules.  Not valid in combination with `--iif' or `--tee'
1765 .TP
1766 .BI "--tee "
1767 Make a copy of the packet, and route that copy to the given destination. For the original, uncopied packet, behave like a non-terminating target and continue traversing the rules.  Not valid in combination with `--iif' or `--continue'
1768 .SS SAME
1769 Similar to SNAT/DNAT depending on chain: it takes a range of addresses
1770 (`--to 1.2.3.4-1.2.3.7') and gives a client the same
1771 source-/destination-address for each connection.
1772 .TP
1773 .BI "--to " "<ipaddr>-<ipaddr>"
1774 Addresses to map source to. May be specified more than once for
1775 multiple ranges.
1776 .TP
1777 .B "--nodst"
1778 Don't use the destination-ip in the calculations when selecting the
1779 new source-ip
1780 .SS SET
1781 This modules adds and/or deletes entries from IP sets which can be defined 
1782 by ipset(8).
1783 .TP
1784 .BR "--add-set " "setname flag[,flag...]"
1785 add the address(es)/port(s) of the packet to the sets
1786 .TP
1787 .BR "--del-set " "setname flag[,flag...]"
1788 delete the address(es)/port(s) of the packet from the sets,
1789 where flags are
1790 .BR "src"
1791 and/or
1792 .BR "dst"
1793 and there can be no more than six of them.
1794 .TP
1795 The bindings to follow must previously be defined in order to use 
1796 multilevel adding/deleting by the SET target.
1797 .SS SNAT
1798 This target is only valid in the
1799 .B nat
1800 table, in the
1801 .B POSTROUTING
1802 chain.  It specifies that the source address of the packet should be
1803 modified (and all future packets in this connection will also be
1804 mangled), and rules should cease being examined.  It takes one type
1805 of option:
1806 .TP
1807 .BR "--to-source  " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]"
1808 which can specify a single new source IP address, an inclusive range
1809 of IP addresses, and optionally, a port range (which is only valid if
1810 the rule also specifies
1811 .B "-p tcp"
1812 or
1813 .BR "-p udp" ).
1814 If no port range is specified, then source ports below 512 will be
1815 mapped to other ports below 512: those between 512 and 1023 inclusive
1816 will be mapped to ports below 1024, and other ports will be mapped to
1817 1024 or above. Where possible, no port alteration will occur.
1818 .RS
1819 .PP
1820 In Kernels up to 2.6.10, you can add several --to-source options.  For those
1821 kernels, if you specify more than one source address, either via an address
1822 range or multiple --to-source options, a simple round-robin (one after another
1823 in cycle) takes place between these addresses.
1824 Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to multiple ranges
1825 anymore.
1826 .SS TARPIT
1827 Captures and holds incoming TCP connections using no local
1828 per-connection resources. Connections are accepted, but immediately
1829 switched to the persist state (0 byte window), in which the remote
1830 side stops sending data and asks to continue every 60-240 seconds.
1831 Attempts to close the connection are ignored, forcing the remote side
1832 to time out the connection in 12-24 minutes.
1833
1834 This offers similar functionality to LaBrea
1835 <http://www.hackbusters.net/LaBrea/> but doesn't require dedicated
1836 hardware or IPs. Any TCP port that you would normally DROP or REJECT
1837 can instead become a tarpit.
1838
1839 To tarpit connections to TCP port 80 destined for the current machine:
1840 .IP
1841 iptables -A INPUT -p tcp -m tcp --dport 80 -j TARPIT
1842 .P
1843 To significantly slow down Code Red/Nimda-style scans of unused address
1844 space, forward unused ip addresses to a Linux box not acting as a router
1845 (e.g. "ip route 10.0.0.0 255.0.0.0 ip.of.linux.box" on a Cisco), enable IP
1846 forwarding on the Linux box, and add:
1847 .IP
1848 iptables -A FORWARD -p tcp -j TARPIT
1849 .IP
1850 iptables -A FORWARD -j DROP
1851 .TP
1852 NOTE:
1853 If you use the conntrack module while you are using TARPIT, you should
1854 also use the NOTRACK target, or the kernel will unnecessarily allocate
1855 resources for each TARPITted connection. To TARPIT incoming
1856 connections to the standard IRC port while using conntrack, you could:
1857 .IP
1858 iptables -t raw -A PREROUTING -p tcp --dport 6667 -j NOTRACK
1859 .IP
1860 iptables -A INPUT -p tcp --dport 6667 -j TARPIT
1861 .SS TCPMSS
1862 This target allows to alter the MSS value of TCP SYN packets, to control
1863 the maximum size for that connection (usually limiting it to your
1864 outgoing interface's MTU minus 40).  Of course, it can only be used
1865 in conjunction with
1866 .BR "-p tcp" .
1867 It is only valid in the
1868 .BR mangle
1869 table.
1870 .br
1871 This target is used to overcome criminally braindead ISPs or servers
1872 which block ICMP Fragmentation Needed packets.  The symptoms of this
1873 problem are that everything works fine from your Linux
1874 firewall/router, but machines behind it can never exchange large
1875 packets:
1876 .PD 0
1877 .RS 0.1i
1878 .TP 0.3i
1879 1)
1880 Web browsers connect, then hang with no data received.
1881 .TP
1882 2)
1883 Small mail works fine, but large emails hang.
1884 .TP
1885 3)
1886 ssh works fine, but scp hangs after initial handshaking.
1887 .RE
1888 .PD
1889 Workaround: activate this option and add a rule to your firewall
1890 configuration like:
1891 .nf
1892  iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN \\
1893              -j TCPMSS --clamp-mss-to-pmtu
1894 .fi
1895 .TP
1896 .BI "--set-mss " "value"
1897 Explicitly set MSS option to specified value.
1898 .TP
1899 .B "--clamp-mss-to-pmtu"
1900 Automatically clamp MSS value to (path_MTU - 40).
1901 .TP
1902 These options are mutually exclusive.
1903 .SS TOS
1904 This is used to set the 8-bit Type of Service field in the IP header.
1905 It is only valid in the
1906 .B mangle
1907 table.
1908 .TP
1909 .BI "--set-tos " "tos"
1910 You can use a numeric TOS values, or use
1911 .nf
1912  iptables -j TOS -h
1913 .fi
1914 to see the list of valid TOS names.
1915 .SS TRACE
1916 This target has no options.  It just turns on 
1917 .B packet tracing
1918 for all packets that match this rule.
1919 .SS TTL
1920 This is used to modify the IPv4 TTL header field.  The TTL field determines
1921 how many hops (routers) a packet can traverse until it's time to live is
1922 exceeded.
1923 .TP
1924 Setting or incrementing the TTL field can potentially be very dangerous,
1925 so it should be avoided at any cost.  
1926 .TP
1927 .B Don't ever set or increment the value on packets that leave your local network!
1928 .B mangle
1929 table.
1930 .TP
1931 .BI "--ttl-set " "value"
1932 Set the TTL value to `value'.
1933 .TP
1934 .BI "--ttl-dec " "value"
1935 Decrement the TTL value `value' times.
1936 .TP
1937 .BI "--ttl-inc " "value"
1938 Increment the TTL value `value' times.
1939 .SS ULOG
1940 This target provides userspace logging of matching packets.  When this
1941 target is set for a rule, the Linux kernel will multicast this packet
1942 through a
1943 .IR netlink 
1944 socket. One or more userspace processes may then subscribe to various 
1945 multicast groups and receive the packets.
1946 Like LOG, this is a "non-terminating target", i.e. rule traversal
1947 continues at the next rule.
1948 .TP
1949 .BI "--ulog-nlgroup " "nlgroup"
1950 This specifies the netlink group (1-32) to which the packet is sent.
1951 Default value is 1.
1952 .TP
1953 .BI "--ulog-prefix " "prefix"
1954 Prefix log messages with the specified prefix; up to 32 characters
1955 long, and useful for distinguishing messages in the logs.
1956 .TP
1957 .BI "--ulog-cprange " "size"
1958 Number of bytes to be copied to userspace.  A value of 0 always copies
1959 the entire packet, regardless of its size.  Default is 0.
1960 .TP
1961 .BI "--ulog-qthreshold " "size"
1962 Number of packet to queue inside kernel.  Setting this value to, e.g. 10
1963 accumulates ten packets inside the kernel and transmits them as one
1964 netlink multipart message to userspace.  Default is 1 (for backwards
1965 compatibility).
1966 .br
1967 .SS XOR
1968 Encrypt TCP and UDP traffic using a simple XOR encryption
1969 .TP
1970 .BI "--key " "string"
1971 Set key to "string"
1972 .TP
1973 .BI "--block-size"
1974 Set block size
1975 .SH DIAGNOSTICS
1976 Various error messages are printed to standard error.  The exit code
1977 is 0 for correct functioning.  Errors which appear to be caused by
1978 invalid or abused command line parameters cause an exit code of 2, and
1979 other errors cause an exit code of 1.
1980 .SH BUGS
1981 Bugs?  What's this? ;-)
1982 Well, you might want to have a look at http://bugzilla.netfilter.org/
1983 .SH COMPATIBILITY WITH IPCHAINS
1984 This
1985 .B iptables
1986 is very similar to ipchains by Rusty Russell.  The main difference is
1987 that the chains
1988 .B INPUT
1989 and
1990 .B OUTPUT
1991 are only traversed for packets coming into the local host and
1992 originating from the local host respectively.  Hence every packet only
1993 passes through one of the three chains (except loopback traffic, which
1994 involves both INPUT and OUTPUT chains); previously a forwarded packet
1995 would pass through all three.
1996 .PP
1997 The other main difference is that
1998 .B -i
1999 refers to the input interface;
2000 .B -o
2001 refers to the output interface, and both are available for packets
2002 entering the
2003 .B FORWARD
2004 chain.
2005 .PP The various forms of NAT have been separated out; 
2006 .B iptables 
2007 is a pure packet filter when using the default `filter' table, with
2008 optional extension modules.  This should simplify much of the previous
2009 confusion over the combination of IP masquerading and packet filtering
2010 seen previously.  So the following options are handled differently:
2011 .nf
2012  -j MASQ
2013  -M -S
2014  -M -L
2015 .fi
2016 There are several other changes in iptables.
2017 .SH SEE ALSO
2018 .BR iptables-save (8),
2019 .BR iptables-restore (8),
2020 .BR ip6tables (8),
2021 .BR ip6tables-save (8),
2022 .BR ip6tables-restore (8),
2023 .BR libipq (3).
2024 .P
2025 The packet-filtering-HOWTO details iptables usage for
2026 packet filtering, the NAT-HOWTO details NAT,
2027 the netfilter-extensions-HOWTO details the extensions that are
2028 not in the standard distribution,
2029 and the netfilter-hacking-HOWTO details the netfilter internals.
2030 .br
2031 See
2032 .BR "http://www.netfilter.org/" .
2033 .SH AUTHORS
2034 Rusty Russell originally wrote iptables, in early consultation with Michael
2035 Neuling.
2036 .PP
2037 Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
2038 selection framework in iptables, then wrote the mangle table, the owner match,
2039 the mark stuff, and ran around doing cool stuff everywhere.
2040 .PP
2041 James Morris wrote the TOS target, and tos match.
2042 .PP
2043 Jozsef Kadlecsik wrote the REJECT target.
2044 .PP
2045 Harald Welte wrote the ULOG and NFQUEUE target, the new libiptc, as well as the TTL, DSCP, ECN matches and targets.
2046 .PP
2047 The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Jozsef Kadlecsik, 
2048 Patrick McHardy, James Morris, Harald Welte and Rusty Russell.
2049 .PP
2050 Man page originally written by Herve Eychenne <rv@wallfire.org>.
2051 .\" .. and did I mention that we are incredibly cool people?
2052 .\" .. sexy, too ..
2053 .\" .. witty, charming, powerful ..
2054 .\" .. and most of all, modest ..