OSDN Git Service

iptables: Update original to 1.4.21
[linuxjm/iptables.git] / original / man8 / iptables-extensions.8
1 .TH iptables-extensions 8 "" "iptables 1.4.21" "iptables 1.4.21"
2 .SH NAME
3 iptables-extensions \(em list of extensions in the standard iptables distribution
4 .SH SYNOPSIS
5 \fBip6tables\fP [\fB\-m\fP \fIname\fP [\fImodule-options\fP...]]
6 [\fB\-j\fP \fItarget-name\fP [\fItarget-options\fP...]
7 .PP
8 \fBiptables\fP [\fB\-m\fP \fIname\fP [\fImodule-options\fP...]]
9 [\fB\-j\fP \fItarget-name\fP [\fItarget-options\fP...]
10 .SH MATCH EXTENSIONS
11 iptables can use extended packet matching modules
12 with the \fB\-m\fP or \fB\-\-match\fP
13 options, followed by the matching module name; after these, various
14 extra command line options become available, depending on the specific
15 module.  You can specify multiple extended match modules in one line,
16 and you can use the \fB\-h\fP or \fB\-\-help\fP
17 options after the module has been specified to receive help specific
18 to that module.  The extended match modules are evaluated in the order
19 they are specified in the rule.
20 .PP
21 If the \fB\-p\fP or \fB\-\-protocol\fP was specified and if and only if an
22 unknown option is encountered, iptables will try load a match module of the
23 same name as the protocol, to try making the option available.
24 .\" @MATCH@
25 .SS addrtype
26 This module matches packets based on their 
27 .B address type.
28 Address types are used within the kernel networking stack and categorize
29 addresses into various groups.  The exact definition of that group depends on the specific layer three protocol.
30 .PP
31 The following address types are possible:
32 .TP
33 .BI "UNSPEC"
34 an unspecified address (i.e. 0.0.0.0)
35 .TP
36 .BI "UNICAST"
37 an unicast address
38 .TP
39 .BI "LOCAL"
40 a local address
41 .TP
42 .BI "BROADCAST"
43 a broadcast address
44 .TP
45 .BI "ANYCAST"
46 an anycast packet
47 .TP
48 .BI "MULTICAST"
49 a multicast address
50 .TP
51 .BI "BLACKHOLE"
52 a blackhole address
53 .TP
54 .BI "UNREACHABLE"
55 an unreachable address
56 .TP
57 .BI "PROHIBIT"
58 a prohibited address
59 .TP
60 .BI "THROW"
61 FIXME
62 .TP
63 .BI "NAT"
64 FIXME
65 .TP
66 .BI "XRESOLVE"
67 .TP
68 [\fB!\fP] \fB\-\-src\-type\fP \fItype\fP
69 Matches if the source address is of given type
70 .TP
71 [\fB!\fP] \fB\-\-dst\-type\fP \fItype\fP
72 Matches if the destination address is of given type
73 .TP
74 .BI "\-\-limit\-iface\-in"
75 The address type checking can be limited to the interface the packet is coming
76 in. This option is only valid in the
77 .BR PREROUTING ,
78 .B INPUT
79 and
80 .B FORWARD
81 chains. It cannot be specified with the
82 \fB\-\-limit\-iface\-out\fP
83 option.
84 .TP
85 \fB\-\-limit\-iface\-out\fP
86 The address type checking can be limited to the interface the packet is going
87 out. This option is only valid in the
88 .BR POSTROUTING ,
89 .B OUTPUT
90 and
91 .B FORWARD
92 chains. It cannot be specified with the
93 \fB\-\-limit\-iface\-in\fP
94 option.
95 .SS ah (IPv6-specific)
96 This module matches the parameters in Authentication header of IPsec packets.
97 .TP
98 [\fB!\fP] \fB\-\-ahspi\fP \fIspi\fP[\fB:\fP\fIspi\fP]
99 Matches SPI.
100 .TP
101 [\fB!\fP] \fB\-\-ahlen\fP \fIlength\fP
102 Total length of this header in octets.
103 .TP
104 \fB\-\-ahres\fP
105 Matches if the reserved field is filled with zero.
106 .SS ah (IPv4-specific)
107 This module matches the SPIs in Authentication header of IPsec packets.
108 .TP
109 [\fB!\fP] \fB\-\-ahspi\fP \fIspi\fP[\fB:\fP\fIspi\fP]
110 .SS bpf
111 Match using Linux Socket Filter. Expects a BPF program in decimal format. This
112 is the format generated by the \fBnfbpf_compile\fP utility.
113 .TP
114 \fB\-\-bytecode\fP \fIcode\fP
115 Pass the BPF byte code format (described in the example below).
116 .PP
117 The code format is similar to the output of the tcpdump -ddd command: one line
118 that stores the number of instructions, followed by one line for each
119 instruction. Instruction lines follow the pattern 'u16 u8 u8 u32' in decimal
120 notation. Fields encode the operation, jump offset if true, jump offset if
121 false and generic multiuse field 'K'. Comments are not supported.
122 .PP
123 For example, to read only packets matching 'ip proto 6', insert the following,
124 without the comments or trailing whitespace:
125 .IP
126 4               # number of instructions
127 .br
128 48 0 0 9        # load byte  ip->proto
129 .br
130 21 0 1 6        # jump equal IPPROTO_TCP
131 .br
132 6 0 0 1         # return     pass (non-zero)
133 .br
134 6 0 0 0         # return     fail (zero)
135 .PP
136 You can pass this filter to the bpf match with the following command:
137 .IP
138 iptables \-A OUTPUT \-m bpf \-\-bytecode '4,48 0 0 9,21 0 1 6,6 0 0 1,6 0 0 0' \-j ACCEPT
139 .PP
140 Or instead, you can invoke the nfbpf_compile utility.
141 .IP
142 iptables \-A OUTPUT \-m bpf \-\-bytecode "`nfbpf_compile RAW 'ip proto 6'`" \-j ACCEPT
143 .PP
144 You may want to learn more about BPF from FreeBSD's bpf(4) manpage.
145 .SS cluster
146 Allows you to deploy gateway and back-end load-sharing clusters without the
147 need of load-balancers.
148 .PP
149 This match requires that all the nodes see the same packets. Thus, the cluster
150 match decides if this node has to handle a packet given the following options:
151 .TP
152 \fB\-\-cluster\-total\-nodes\fP \fInum\fP
153 Set number of total nodes in cluster.
154 .TP
155 [\fB!\fP] \fB\-\-cluster\-local\-node\fP \fInum\fP
156 Set the local node number ID.
157 .TP
158 [\fB!\fP] \fB\-\-cluster\-local\-nodemask\fP \fImask\fP
159 Set the local node number ID mask. You can use this option instead
160 of \fB\-\-cluster\-local\-node\fP.
161 .TP
162 \fB\-\-cluster\-hash\-seed\fP \fIvalue\fP
163 Set seed value of the Jenkins hash.
164 .PP
165 Example:
166 .IP
167 iptables \-A PREROUTING \-t mangle \-i eth1 \-m cluster
168 \-\-cluster\-total\-nodes 2 \-\-cluster\-local\-node 1
169 \-\-cluster\-hash\-seed 0xdeadbeef
170 \-j MARK \-\-set-mark 0xffff
171 .IP
172 iptables \-A PREROUTING \-t mangle \-i eth2 \-m cluster
173 \-\-cluster\-total\-nodes 2 \-\-cluster\-local\-node 1
174 \-\-cluster\-hash\-seed 0xdeadbeef
175 \-j MARK -\-set\-mark 0xffff
176 .IP
177 iptables \-A PREROUTING \-t mangle \-i eth1
178 \-m mark ! \-\-mark 0xffff \-j DROP
179 .IP
180 iptables \-A PREROUTING \-t mangle \-i eth2
181 \-m mark ! \-\-mark 0xffff \-j DROP
182 .PP
183 And the following commands to make all nodes see the same packets:
184 .IP
185 ip maddr add 01:00:5e:00:01:01 dev eth1
186 .IP
187 ip maddr add 01:00:5e:00:01:02 dev eth2
188 .IP
189 arptables \-A OUTPUT \-o eth1 \-\-h\-length 6
190 \-j mangle \-\-mangle-mac-s 01:00:5e:00:01:01
191 .IP
192 arptables \-A INPUT \-i eth1 \-\-h-length 6
193 \-\-destination-mac 01:00:5e:00:01:01
194 \-j mangle \-\-mangle\-mac\-d 00:zz:yy:xx:5a:27
195 .IP
196 arptables \-A OUTPUT \-o eth2 \-\-h\-length 6
197 \-j mangle \-\-mangle\-mac\-s 01:00:5e:00:01:02
198 .IP
199 arptables \-A INPUT \-i eth2 \-\-h\-length 6
200 \-\-destination\-mac 01:00:5e:00:01:02
201 \-j mangle \-\-mangle\-mac\-d 00:zz:yy:xx:5a:27
202 .PP
203 \fBNOTE\fP: the arptables commands above use mainstream syntax. If you
204 are using arptables-jf included in some RedHat, CentOS and Fedora
205 versions, you will hit syntax errors. Therefore, you'll have to adapt
206 these to the arptables-jf syntax to get them working.
207 .PP
208 In the case of TCP connections, pickup facility has to be disabled
209 to avoid marking TCP ACK packets coming in the reply direction as
210 valid.
211 .IP
212 echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose
213 .SS comment
214 Allows you to add comments (up to 256 characters) to any rule.
215 .TP
216 \fB\-\-comment\fP \fIcomment\fP
217 .TP
218 Example:
219 iptables \-A INPUT \-i eth1 \-m comment \-\-comment "my local LAN"
220 .SS connbytes
221 Match by how many bytes or packets a connection (or one of the two
222 flows constituting the connection) has transferred so far, or by
223 average bytes per packet.
224 .PP
225 The counters are 64-bit and are thus not expected to overflow ;)
226 .PP
227 The primary use is to detect long-lived downloads and mark them to be
228 scheduled using a lower priority band in traffic control.
229 .PP
230 The transferred bytes per connection can also be viewed through
231 `conntrack \-L` and accessed via ctnetlink.
232 .PP
233 NOTE that for connections which have no accounting information, the match will
234 always return false. The "net.netfilter.nf_conntrack_acct" sysctl flag controls
235 whether \fBnew\fP connections will be byte/packet counted. Existing connection
236 flows will not be gaining/losing a/the accounting structure when be sysctl flag
237 is flipped.
238 .TP
239 [\fB!\fP] \fB\-\-connbytes\fP \fIfrom\fP[\fB:\fP\fIto\fP]
240 match packets from a connection whose packets/bytes/average packet
241 size is more than FROM and less than TO bytes/packets. if TO is
242 omitted only FROM check is done. "!" is used to match packets not
243 falling in the range.
244 .TP
245 \fB\-\-connbytes\-dir\fP {\fBoriginal\fP|\fBreply\fP|\fBboth\fP}
246 which packets to consider
247 .TP
248 \fB\-\-connbytes\-mode\fP {\fBpackets\fP|\fBbytes\fP|\fBavgpkt\fP}
249 whether to check the amount of packets, number of bytes transferred or
250 the average size (in bytes) of all packets received so far. Note that
251 when "both" is used together with "avgpkt", and data is going (mainly)
252 only in one direction (for example HTTP), the average packet size will
253 be about half of the actual data packets.
254 .TP
255 Example:
256 iptables .. \-m connbytes \-\-connbytes 10000:100000 \-\-connbytes\-dir both \-\-connbytes\-mode bytes ...
257 .SS connlimit
258 Allows you to restrict the number of parallel connections to a server per
259 client IP address (or client address block).
260 .TP
261 \fB\-\-connlimit\-upto\fP \fIn\fP
262 Match if the number of existing connections is below or equal \fIn\fP.
263 .TP
264 \fB\-\-connlimit\-above\fP \fIn\fP
265 Match if the number of existing connections is above \fIn\fP.
266 .TP
267 \fB\-\-connlimit\-mask\fP \fIprefix_length\fP
268 Group hosts using the prefix length. For IPv4, this must be a number between
269 (including) 0 and 32. For IPv6, between 0 and 128. If not specified, the
270 maximum prefix length for the applicable protocol is used.
271 .TP
272 \fB\-\-connlimit\-saddr\fP
273 Apply the limit onto the source group. This is the default if
274 \-\-connlimit\-daddr is not specified.
275 .TP
276 \fB\-\-connlimit\-daddr\fP
277 Apply the limit onto the destination group.
278 .PP
279 Examples:
280 .TP
281 # allow 2 telnet connections per client host
282 iptables \-A INPUT \-p tcp \-\-syn \-\-dport 23 \-m connlimit \-\-connlimit\-above 2 \-j REJECT
283 .TP
284 # you can also match the other way around:
285 iptables \-A INPUT \-p tcp \-\-syn \-\-dport 23 \-m connlimit \-\-connlimit\-upto 2 \-j ACCEPT
286 .TP
287 # limit the number of parallel HTTP requests to 16 per class C sized \
288 source network (24 bit netmask)
289 iptables \-p tcp \-\-syn \-\-dport 80 \-m connlimit \-\-connlimit\-above 16
290 \-\-connlimit\-mask 24 \-j REJECT
291 .TP
292 # limit the number of parallel HTTP requests to 16 for the link local network
293 (ipv6)
294 ip6tables \-p tcp \-\-syn \-\-dport 80 \-s fe80::/64 \-m connlimit \-\-connlimit\-above
295 16 \-\-connlimit\-mask 64 \-j REJECT
296 .TP
297 # Limit the number of connections to a particular host:
298 ip6tables \-p tcp \-\-syn \-\-dport 49152:65535 \-d 2001:db8::1 \-m connlimit
299 \-\-connlimit-above 100 \-j REJECT
300 .SS connmark
301 This module matches the netfilter mark field associated with a connection
302 (which can be set using the \fBCONNMARK\fP target below).
303 .TP
304 [\fB!\fP] \fB\-\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
305 Matches packets in connections with the given mark value (if a mask is
306 specified, this is logically ANDed with the mark before the comparison).
307 .SS conntrack
308 This module, when combined with connection tracking, allows access to the
309 connection tracking state for this packet/connection.
310 .TP
311 [\fB!\fP] \fB\-\-ctstate\fP \fIstatelist\fP
312 \fIstatelist\fP is a comma separated list of the connection states to match.
313 Possible states are listed below.
314 .TP
315 [\fB!\fP] \fB\-\-ctproto\fP \fIl4proto\fP
316 Layer-4 protocol to match (by number or name)
317 .TP
318 [\fB!\fP] \fB\-\-ctorigsrc\fP \fIaddress\fP[\fB/\fP\fImask\fP]
319 .TP
320 [\fB!\fP] \fB\-\-ctorigdst\fP \fIaddress\fP[\fB/\fP\fImask\fP]
321 .TP
322 [\fB!\fP] \fB\-\-ctreplsrc\fP \fIaddress\fP[\fB/\fP\fImask\fP]
323 .TP
324 [\fB!\fP] \fB\-\-ctrepldst\fP \fIaddress\fP[\fB/\fP\fImask\fP]
325 Match against original/reply source/destination address
326 .TP
327 [\fB!\fP] \fB\-\-ctorigsrcport\fP \fIport\fP[\fB:\fP\fIport\fP]
328 .TP
329 [\fB!\fP] \fB\-\-ctorigdstport\fP \fIport\fP[\fB:\fP\fIport\fP]
330 .TP
331 [\fB!\fP] \fB\-\-ctreplsrcport\fP \fIport\fP[\fB:\fP\fIport\fP]
332 .TP
333 [\fB!\fP] \fB\-\-ctrepldstport\fP \fIport\fP[\fB:\fP\fIport\fP]
334 Match against original/reply source/destination port (TCP/UDP/etc.) or GRE key.
335 Matching against port ranges is only supported in kernel versions above 2.6.38.
336 .TP
337 [\fB!\fP] \fB\-\-ctstatus\fP \fIstatelist\fP
338 \fIstatuslist\fP is a comma separated list of the connection statuses to match.
339 Possible statuses are listed below.
340 .TP
341 [\fB!\fP] \fB\-\-ctexpire\fP \fItime\fP[\fB:\fP\fItime\fP]
342 Match remaining lifetime in seconds against given value or range of values
343 (inclusive)
344 .TP
345 \fB\-\-ctdir\fP {\fBORIGINAL\fP|\fBREPLY\fP}
346 Match packets that are flowing in the specified direction. If this flag is not
347 specified at all, matches packets in both directions.
348 .PP
349 States for \fB\-\-ctstate\fP:
350 .TP
351 \fBINVALID\fP
352 The packet is associated with no known connection.
353 .TP
354 \fBNEW\fP
355 The packet has started a new connection or otherwise associated
356 with a connection which has not seen packets in both directions.
357 .TP
358 \fBESTABLISHED\fP
359 The packet is associated with a connection which has seen packets
360 in both directions.
361 .TP
362 \fBRELATED\fP
363 The packet is starting a new connection, but is associated with an
364 existing connection, such as an FTP data transfer or an ICMP error.
365 .TP
366 \fBUNTRACKED\fP
367 The packet is not tracked at all, which happens if you explicitly untrack it
368 by using \-j CT \-\-notrack in the raw table.
369 .TP
370 \fBSNAT\fP
371 A virtual state, matching if the original source address differs from the reply
372 destination.
373 .TP
374 \fBDNAT\fP
375 A virtual state, matching if the original destination differs from the reply
376 source.
377 .PP
378 Statuses for \fB\-\-ctstatus\fP:
379 .TP
380 \fBNONE\fP
381 None of the below.
382 .TP
383 \fBEXPECTED\fP
384 This is an expected connection (i.e. a conntrack helper set it up).
385 .TP
386 \fBSEEN_REPLY\fP
387 Conntrack has seen packets in both directions.
388 .TP
389 \fBASSURED\fP
390 Conntrack entry should never be early-expired.
391 .TP
392 \fBCONFIRMED\fP
393 Connection is confirmed: originating packet has left box.
394 .SS cpu
395 .TP
396 [\fB!\fP] \fB\-\-cpu\fP \fInumber\fP
397 Match cpu handling this packet. cpus are numbered from 0 to NR_CPUS-1
398 Can be used in combination with RPS (Remote Packet Steering) or
399 multiqueue NICs to spread network traffic on different queues.
400 .PP
401 Example:
402 .PP
403 iptables \-t nat \-A PREROUTING \-p tcp \-\-dport 80 \-m cpu \-\-cpu 0 
404 \-j REDIRECT \-\-to\-port 8080
405 .PP
406 iptables \-t nat \-A PREROUTING \-p tcp \-\-dport 80 \-m cpu \-\-cpu 1 
407 \-j REDIRECT \-\-to\-port 8081
408 .PP
409 Available since Linux 2.6.36.
410 .SS dccp
411 .TP
412 [\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP]
413 .TP
414 [\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP]
415 .TP
416 [\fB!\fP] \fB\-\-dccp\-types\fP \fImask\fP
417 Match when the DCCP packet type is one of 'mask'. 'mask' is a comma-separated
418 list of packet types.  Packet types are: 
419 .BR "REQUEST RESPONSE DATA ACK DATAACK CLOSEREQ CLOSE RESET SYNC SYNCACK INVALID" .
420 .TP
421 [\fB!\fP] \fB\-\-dccp\-option\fP \fInumber\fP
422 Match if DCCP option set.
423 .SS devgroup
424 Match device group of a packets incoming/outgoing interface.
425 .TP
426 [\fB!\fP] \fB\-\-src\-group\fP \fIname\fP
427 Match device group of incoming device
428 .TP
429 [\fB!\fP] \fB\-\-dst\-group\fP \fIname\fP
430 Match device group of outgoing device
431 .SS dscp
432 This module matches the 6 bit DSCP field within the TOS field in the
433 IP header.  DSCP has superseded TOS within the IETF.
434 .TP
435 [\fB!\fP] \fB\-\-dscp\fP \fIvalue\fP
436 Match against a numeric (decimal or hex) value [0-63].
437 .TP
438 [\fB!\fP] \fB\-\-dscp\-class\fP \fIclass\fP
439 Match the DiffServ class. This value may be any of the
440 BE, EF, AFxx or CSx classes.  It will then be converted
441 into its according numeric value.
442 .SS dst (IPv6-specific)
443 This module matches the parameters in Destination Options header
444 .TP
445 [\fB!\fP] \fB\-\-dst\-len\fP \fIlength\fP
446 Total length of this header in octets.
447 .TP
448 \fB\-\-dst\-opts\fP \fItype\fP[\fB:\fP\fIlength\fP][\fB,\fP\fItype\fP[\fB:\fP\fIlength\fP]...]
449 numeric type of option and the length of the option data in octets.
450 .SS ecn
451 This allows you to match the ECN bits of the IPv4/IPv6 and TCP header.  ECN is the Explicit Congestion Notification mechanism as specified in RFC3168
452 .TP
453 [\fB!\fP] \fB\-\-ecn\-tcp\-cwr\fP
454 This matches if the TCP ECN CWR (Congestion Window Received) bit is set.
455 .TP
456 [\fB!\fP] \fB\-\-ecn\-tcp\-ece\fP
457 This matches if the TCP ECN ECE (ECN Echo) bit is set.
458 .TP
459 [\fB!\fP] \fB\-\-ecn\-ip\-ect\fP \fInum\fP
460 This matches a particular IPv4/IPv6 ECT (ECN-Capable Transport). You have to specify
461 a number between `0' and `3'.
462 .SS esp
463 This module matches the SPIs in ESP header of IPsec packets.
464 .TP
465 [\fB!\fP] \fB\-\-espspi\fP \fIspi\fP[\fB:\fP\fIspi\fP]
466 .SS eui64 (IPv6-specific)
467 This module matches the EUI-64 part of a stateless autoconfigured IPv6 address.
468 It compares the EUI-64 derived from the source MAC address in Ethernet frame
469 with the lower 64 bits of the IPv6 source address. But "Universal/Local"
470 bit is not compared. This module doesn't match other link layer frame, and
471 is only valid in the
472 .BR PREROUTING ,
473 .BR INPUT
474 and
475 .BR FORWARD
476 chains.
477 .SS frag (IPv6-specific)
478 This module matches the parameters in Fragment header.
479 .TP
480 [\fB!\fP] \fB\-\-fragid\fP \fIid\fP[\fB:\fP\fIid\fP]
481 Matches the given Identification or range of it.
482 .TP
483 [\fB!\fP] \fB\-\-fraglen\fP \fIlength\fP
484 This option cannot be used with kernel version 2.6.10 or later. The length of
485 Fragment header is static and this option doesn't make sense.
486 .TP
487 \fB\-\-fragres\fP
488 Matches if the reserved fields are filled with zero.
489 .TP
490 \fB\-\-fragfirst\fP
491 Matches on the first fragment.
492 .TP
493 \fB\-\-fragmore\fP
494 Matches if there are more fragments.
495 .TP
496 \fB\-\-fraglast\fP
497 Matches if this is the last fragment.
498 .SS hashlimit
499 \fBhashlimit\fP uses hash buckets to express a rate limiting match (like the
500 \fBlimit\fP match) for a group of connections using a \fBsingle\fP iptables
501 rule. Grouping can be done per-hostgroup (source and/or destination address)
502 and/or per-port. It gives you the ability to express "\fIN\fP packets per time
503 quantum per group" or "\fIN\fP bytes per seconds" (see below for some examples).
504 .PP
505 A hash limit option (\fB\-\-hashlimit\-upto\fP, \fB\-\-hashlimit\-above\fP) and
506 \fB\-\-hashlimit\-name\fP are required.
507 .TP
508 \fB\-\-hashlimit\-upto\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP]
509 Match if the rate is below or equal to \fIamount\fP/quantum. It is specified either as
510 a number, with an optional time quantum suffix (the default is 3/hour), or as
511 \fIamount\fPb/second (number of bytes per second).
512 .TP
513 \fB\-\-hashlimit\-above\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP]
514 Match if the rate is above \fIamount\fP/quantum.
515 .TP
516 \fB\-\-hashlimit\-burst\fP \fIamount\fP
517 Maximum initial number of packets to match: this number gets recharged by one
518 every time the limit specified above is not reached, up to this number; the
519 default is 5.  When byte-based rate matching is requested, this option specifies
520 the amount of bytes that can exceed the given rate.  This option should be used
521 with caution -- if the entry expires, the burst value is reset too.
522 .TP
523 \fB\-\-hashlimit\-mode\fP {\fBsrcip\fP|\fBsrcport\fP|\fBdstip\fP|\fBdstport\fP}\fB,\fP...
524 A comma-separated list of objects to take into consideration. If no
525 \-\-hashlimit\-mode option is given, hashlimit acts like limit, but at the
526 expensive of doing the hash housekeeping.
527 .TP
528 \fB\-\-hashlimit\-srcmask\fP \fIprefix\fP
529 When \-\-hashlimit\-mode srcip is used, all source addresses encountered will be
530 grouped according to the given prefix length and the so-created subnet will be
531 subject to hashlimit. \fIprefix\fP must be between (inclusive) 0 and 32. Note
532 that \-\-hashlimit\-srcmask 0 is basically doing the same thing as not specifying
533 srcip for \-\-hashlimit\-mode, but is technically more expensive.
534 .TP
535 \fB\-\-hashlimit\-dstmask\fP \fIprefix\fP
536 Like \-\-hashlimit\-srcmask, but for destination addresses.
537 .TP
538 \fB\-\-hashlimit\-name\fP \fIfoo\fP
539 The name for the /proc/net/ipt_hashlimit/foo entry.
540 .TP
541 \fB\-\-hashlimit\-htable\-size\fP \fIbuckets\fP
542 The number of buckets of the hash table
543 .TP
544 \fB\-\-hashlimit\-htable\-max\fP \fIentries\fP
545 Maximum entries in the hash.
546 .TP
547 \fB\-\-hashlimit\-htable\-expire\fP \fImsec\fP
548 After how many milliseconds do hash entries expire.
549 .TP
550 \fB\-\-hashlimit\-htable\-gcinterval\fP \fImsec\fP
551 How many milliseconds between garbage collection intervals.
552 .PP
553 Examples:
554 .TP
555 matching on source host
556 "1000 packets per second for every host in 192.168.0.0/16" =>
557 \-s 192.168.0.0/16 \-\-hashlimit\-mode srcip \-\-hashlimit\-upto 1000/sec
558 .TP
559 matching on source port
560 "100 packets per second for every service of 192.168.1.1" =>
561 \-s 192.168.1.1 \-\-hashlimit\-mode srcport \-\-hashlimit\-upto 100/sec
562 .TP
563 matching on subnet
564 "10000 packets per minute for every /28 subnet (groups of 8 addresses)
565 in 10.0.0.0/8" =>
566 \-s 10.0.0.0/8 \-\-hashlimit\-mask 28 \-\-hashlimit\-upto 10000/min
567 .TP
568 matching bytes per second
569 "flows exceeding 512kbyte/s" =>
570 \-\-hashlimit-mode srcip,dstip,srcport,dstport \-\-hashlimit\-above 512kb/s
571 .TP
572 matching bytes per second
573 "hosts that exceed 512kbyte/s, but permit up to 1Megabytes without matching"
574 \-\-hashlimit-mode dstip \-\-hashlimit\-above 512kb/s \-\-hashlimit-burst 1mb
575 .SS hbh (IPv6-specific)
576 This module matches the parameters in Hop-by-Hop Options header
577 .TP
578 [\fB!\fP] \fB\-\-hbh\-len\fP \fIlength\fP
579 Total length of this header in octets.
580 .TP
581 \fB\-\-hbh\-opts\fP \fItype\fP[\fB:\fP\fIlength\fP][\fB,\fP\fItype\fP[\fB:\fP\fIlength\fP]...]
582 numeric type of option and the length of the option data in octets.
583 .SS helper
584 This module matches packets related to a specific conntrack-helper.
585 .TP
586 [\fB!\fP] \fB\-\-helper\fP \fIstring\fP
587 Matches packets related to the specified conntrack-helper.
588 .RS
589 .PP
590 string can be "ftp" for packets related to a ftp-session on default port.
591 For other ports append \-portnr to the value, ie. "ftp\-2121".
592 .PP
593 Same rules apply for other conntrack-helpers.
594 .RE
595 .SS hl (IPv6-specific)
596 This module matches the Hop Limit field in the IPv6 header.
597 .TP
598 [\fB!\fP] \fB\-\-hl\-eq\fP \fIvalue\fP
599 Matches if Hop Limit equals \fIvalue\fP.
600 .TP
601 \fB\-\-hl\-lt\fP \fIvalue\fP
602 Matches if Hop Limit is less than \fIvalue\fP.
603 .TP
604 \fB\-\-hl\-gt\fP \fIvalue\fP
605 Matches if Hop Limit is greater than \fIvalue\fP.
606 .SS icmp (IPv4-specific)
607 This extension can be used if `\-\-protocol icmp' is specified. It
608 provides the following option:
609 .TP
610 [\fB!\fP] \fB\-\-icmp\-type\fP {\fItype\fP[\fB/\fP\fIcode\fP]|\fItypename\fP}
611 This allows specification of the ICMP type, which can be a numeric
612 ICMP type, type/code pair, or one of the ICMP type names shown by the command
613 .nf
614  iptables \-p icmp \-h
615 .fi
616 .SS icmp6 (IPv6-specific)
617 This extension can be used if `\-\-protocol ipv6\-icmp' or `\-\-protocol icmpv6' is
618 specified. It provides the following option:
619 .TP
620 [\fB!\fP] \fB\-\-icmpv6\-type\fP \fItype\fP[\fB/\fP\fIcode\fP]|\fItypename\fP
621 This allows specification of the ICMPv6 type, which can be a numeric
622 ICMPv6
623 .IR type ,
624 .IR type
625 and
626 .IR code ,
627 or one of the ICMPv6 type names shown by the command
628 .nf
629  ip6tables \-p ipv6\-icmp \-h
630 .fi
631 .SS iprange
632 This matches on a given arbitrary range of IP addresses.
633 .TP
634 [\fB!\fP] \fB\-\-src\-range\fP \fIfrom\fP[\fB\-\fP\fIto\fP]
635 Match source IP in the specified range.
636 .TP
637 [\fB!\fP] \fB\-\-dst\-range\fP \fIfrom\fP[\fB\-\fP\fIto\fP]
638 Match destination IP in the specified range.
639 .SS ipv6header (IPv6-specific)
640 This module matches IPv6 extension headers and/or upper layer header.
641 .TP
642 \fB\-\-soft\fP
643 Matches if the packet includes \fBany\fP of the headers specified with
644 \fB\-\-header\fP.
645 .TP
646 [\fB!\fP] \fB\-\-header\fP \fIheader\fP[\fB,\fP\fIheader\fP...]
647 Matches the packet which EXACTLY includes all specified headers. The headers
648 encapsulated with ESP header are out of scope.
649 Possible \fIheader\fP types can be:
650 .TP
651 \fBhop\fP|\fBhop\-by\-hop\fP
652 Hop-by-Hop Options header
653 .TP
654 \fBdst\fP
655 Destination Options header
656 .TP
657 \fBroute\fP
658 Routing header
659 .TP
660 \fBfrag\fP
661 Fragment header
662 .TP
663 \fBauth\fP
664 Authentication header
665 .TP
666 \fBesp\fP
667 Encapsulating Security Payload header
668 .TP
669 \fBnone\fP
670 No Next header which matches 59 in the 'Next Header field' of IPv6 header or
671 any IPv6 extension headers
672 .TP
673 \fBproto\fP
674 which matches any upper layer protocol header. A protocol name from
675 /etc/protocols and numeric value also allowed. The number 255 is equivalent to
676 \fBproto\fP.
677 .SS ipvs
678 Match IPVS connection properties.
679 .TP
680 [\fB!\fP] \fB\-\-ipvs\fP
681 packet belongs to an IPVS connection
682 .TP
683 Any of the following options implies \-\-ipvs (even negated)
684 .TP
685 [\fB!\fP] \fB\-\-vproto\fP \fIprotocol\fP
686 VIP protocol to match; by number or name, e.g. "tcp"
687 .TP
688 [\fB!\fP] \fB\-\-vaddr\fP \fIaddress\fP[\fB/\fP\fImask\fP]
689 VIP address to match
690 .TP
691 [\fB!\fP] \fB\-\-vport\fP \fIport\fP
692 VIP port to match; by number or name, e.g. "http"
693 .TP
694 \fB\-\-vdir\fP {\fBORIGINAL\fP|\fBREPLY\fP}
695 flow direction of packet
696 .TP
697 [\fB!\fP] \fB\-\-vmethod\fP {\fBGATE\fP|\fBIPIP\fP|\fBMASQ\fP}
698 IPVS forwarding method used
699 .TP
700 [\fB!\fP] \fB\-\-vportctl\fP \fIport\fP
701 VIP port of the controlling connection to match, e.g. 21 for FTP
702 .SS length
703 This module matches the length of the layer-3 payload (e.g. layer-4 packet)
704 of a packet against a specific value
705 or range of values.
706 .TP
707 [\fB!\fP] \fB\-\-length\fP \fIlength\fP[\fB:\fP\fIlength\fP]
708 .SS limit
709 This module matches at a limited rate using a token bucket filter.
710 A rule using this extension will match until this limit is reached.
711 It can be used in combination with the
712 .B LOG
713 target to give limited logging, for example.
714 .PP
715 xt_limit has no negation support - you will have to use \-m hashlimit !
716 \-\-hashlimit \fIrate\fP in this case whilst omitting \-\-hashlimit\-mode.
717 .TP
718 \fB\-\-limit\fP \fIrate\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP]
719 Maximum average matching rate: specified as a number, with an optional
720 `/second', `/minute', `/hour', or `/day' suffix; the default is
721 3/hour.
722 .TP
723 \fB\-\-limit\-burst\fP \fInumber\fP
724 Maximum initial number of packets to match: this number gets
725 recharged by one every time the limit specified above is not reached,
726 up to this number; the default is 5.
727 .SS mac
728 .TP
729 [\fB!\fP] \fB\-\-mac\-source\fP \fIaddress\fP
730 Match source MAC address.  It must be of the form XX:XX:XX:XX:XX:XX.
731 Note that this only makes sense for packets coming from an Ethernet device
732 and entering the
733 .BR PREROUTING ,
734 .B FORWARD
735 or
736 .B INPUT
737 chains.
738 .SS mark
739 This module matches the netfilter mark field associated with a packet
740 (which can be set using the
741 .B MARK
742 target below).
743 .TP
744 [\fB!\fP] \fB\-\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
745 Matches packets with the given unsigned mark value (if a \fImask\fP is
746 specified, this is logically ANDed with the \fImask\fP before the
747 comparison).
748 .SS mh (IPv6-specific)
749 This extension is loaded if `\-\-protocol ipv6\-mh' or `\-\-protocol mh' is
750 specified. It provides the following option:
751 .TP
752 [\fB!\fP] \fB\-\-mh\-type\fP \fItype\fP[\fB:\fP\fItype\fP]
753 This allows specification of the Mobility Header(MH) type, which can be
754 a numeric MH
755 .IR type ,
756 .IR type
757 or one of the MH type names shown by the command
758 .nf
759  ip6tables \-p mh \-h
760 .fi
761 .SS multiport
762 This module matches a set of source or destination ports.  Up to 15
763 ports can be specified.  A port range (port:port) counts as two
764 ports.  It can only be used in conjunction with one of the
765 following protocols:
766 \fBtcp\fP, \fBudp\fP, \fBudplite\fP, \fBdccp\fP and \fBsctp\fP.
767 .TP
768 [\fB!\fP] \fB\-\-source\-ports\fP,\fB\-\-sports\fP \fIport\fP[\fB,\fP\fIport\fP|\fB,\fP\fIport\fP\fB:\fP\fIport\fP]...
769 Match if the source port is one of the given ports.  The flag
770 \fB\-\-sports\fP
771 is a convenient alias for this option. Multiple ports or port ranges are
772 separated using a comma, and a port range is specified using a colon.
773 \fB53,1024:65535\fP would therefore match ports 53 and all from 1024 through
774 65535.
775 .TP
776 [\fB!\fP] \fB\-\-destination\-ports\fP,\fB\-\-dports\fP \fIport\fP[\fB,\fP\fIport\fP|\fB,\fP\fIport\fP\fB:\fP\fIport\fP]...
777 Match if the destination port is one of the given ports.  The flag
778 \fB\-\-dports\fP
779 is a convenient alias for this option.
780 .TP
781 [\fB!\fP] \fB\-\-ports\fP \fIport\fP[\fB,\fP\fIport\fP|\fB,\fP\fIport\fP\fB:\fP\fIport\fP]...
782 Match if either the source or destination ports are equal to one of
783 the given ports.
784 .SS nfacct
785 The nfacct match provides the extended accounting infrastructure for iptables.
786 You have to use this match together with the standalone user-space utility
787 .B nfacct(8)
788 .PP
789 The only option available for this match is the following:
790 .TP
791 \fB\-\-nfacct\-name\fP \fIname\fP
792 This allows you to specify the existing object name that will be use for
793 accounting the traffic that this rule-set is matching.
794 .PP
795 To use this extension, you have to create an accounting object:
796 .IP
797 nfacct add http\-traffic
798 .PP
799 Then, you have to attach it to the accounting object via iptables:
800 .IP
801 iptables \-I INPUT \-p tcp \-\-sport 80 \-m nfacct \-\-nfacct\-name http\-traffic
802 .IP
803 iptables \-I OUTPUT \-p tcp \-\-dport 80 \-m nfacct \-\-nfacct\-name http\-traffic
804 .PP
805 Then, you can check for the amount of traffic that the rules match:
806 .IP
807 nfacct get http\-traffic
808 .IP
809 { pkts = 00000000000000000156, bytes = 00000000000000151786 } = http-traffic;
810 .PP
811 You can obtain
812 .B nfacct(8)
813 from http://www.netfilter.org or, alternatively, from the git.netfilter.org
814 repository.
815 .SS osf
816 The osf module does passive operating system fingerprinting. This modules
817 compares some data (Window Size, MSS, options and their order, TTL, DF,
818 and others) from packets with the SYN bit set. 
819 .TP
820 [\fB!\fP] \fB\-\-genre\fP \fIstring\fP
821 Match an operating system genre by using a passive fingerprinting.
822 .TP
823 \fB\-\-ttl\fP \fIlevel\fP
824 Do additional TTL checks on the packet to determine the operating system.
825 \fIlevel\fP can be one of the following values:
826 .IP \(bu 4
827 0 - True IP address and fingerprint TTL comparison. This generally works for
828 LANs.
829 .IP \(bu 4
830 1 - Check if the IP header's TTL is less than the fingerprint one. Works for
831 globally-routable addresses.
832 .IP \(bu 4
833 2 - Do not compare the TTL at all.
834 .TP
835 \fB\-\-log\fP \fIlevel\fP
836 Log determined genres into dmesg even if they do not match the desired one.
837 \fIlevel\fP can be one of the following values:
838 .IP \(bu 4
839 0 - Log all matched or unknown signatures
840 .IP \(bu 4
841 1 - Log only the first one
842 .IP \(bu 4
843 2 - Log all known matched signatures
844 .PP
845 You may find something like this in syslog:
846 .PP
847 Windows [2000:SP3:Windows XP Pro SP1, 2000 SP3]: 11.22.33.55:4024 ->
848 11.22.33.44:139 hops=3 Linux [2.5-2.6:] : 1.2.3.4:42624 -> 1.2.3.5:22 hops=4
849 .PP
850 OS fingerprints are loadable using the \fBnfnl_osf\fP program. To load
851 fingerprints from a file, use:
852 .PP
853 \fBnfnl_osf -f /usr/share/xtables/pf.os\fP
854 .PP
855 To remove them again,
856 .PP
857 \fBnfnl_osf -f /usr/share/xtables/pf.os -d\fP
858 .PP
859 The fingerprint database can be downlaoded from
860 http://www.openbsd.org/cgi-bin/cvsweb/src/etc/pf.os .
861 .SS owner
862 This module attempts to match various characteristics of the packet creator,
863 for locally generated packets. This match is only valid in the OUTPUT and
864 POSTROUTING chains. Forwarded packets do not have any socket associated with
865 them. Packets from kernel threads do have a socket, but usually no owner.
866 .TP
867 [\fB!\fP] \fB\-\-uid\-owner\fP \fIusername\fP
868 .TP
869 [\fB!\fP] \fB\-\-uid\-owner\fP \fIuserid\fP[\fB\-\fP\fIuserid\fP]
870 Matches if the packet socket's file structure (if it has one) is owned by the
871 given user. You may also specify a numerical UID, or an UID range.
872 .TP
873 [\fB!\fP] \fB\-\-gid\-owner\fP \fIgroupname\fP
874 .TP
875 [\fB!\fP] \fB\-\-gid\-owner\fP \fIgroupid\fP[\fB\-\fP\fIgroupid\fP]
876 Matches if the packet socket's file structure is owned by the given group.
877 You may also specify a numerical GID, or a GID range.
878 .TP
879 [\fB!\fP] \fB\-\-socket\-exists\fP
880 Matches if the packet is associated with a socket.
881 .SS physdev
882 This module matches on the bridge port input and output devices enslaved
883 to a bridge device. This module is a part of the infrastructure that enables
884 a transparent bridging IP firewall and is only useful for kernel versions
885 above version 2.5.44.
886 .TP
887 [\fB!\fP] \fB\-\-physdev\-in\fP \fIname\fP
888 Name of a bridge port via which a packet is received (only for
889 packets entering the
890 .BR INPUT ,
891 .B FORWARD
892 and
893 .B PREROUTING
894 chains). If the interface name ends in a "+", then any
895 interface which begins with this name will match. If the packet didn't arrive
896 through a bridge device, this packet won't match this option, unless '!' is used.
897 .TP
898 [\fB!\fP] \fB\-\-physdev\-out\fP \fIname\fP
899 Name of a bridge port via which a packet is going to be sent (for packets
900 entering the
901 .BR FORWARD ,
902 .B OUTPUT
903 and
904 .B POSTROUTING
905 chains).  If the interface name ends in a "+", then any
906 interface which begins with this name will match. Note that in the
907 .BR nat " and " mangle
908 .B OUTPUT
909 chains one cannot match on the bridge output port, however one can in the
910 .B "filter OUTPUT"
911 chain. If the packet won't leave by a bridge device or if it is yet unknown what
912 the output device will be, then the packet won't match this option,
913 unless '!' is used.
914 .TP
915 [\fB!\fP] \fB\-\-physdev\-is\-in\fP
916 Matches if the packet has entered through a bridge interface.
917 .TP
918 [\fB!\fP] \fB\-\-physdev\-is\-out\fP
919 Matches if the packet will leave through a bridge interface.
920 .TP
921 [\fB!\fP] \fB\-\-physdev\-is\-bridged\fP
922 Matches if the packet is being bridged and therefore is not being routed.
923 This is only useful in the FORWARD and POSTROUTING chains.
924 .SS pkttype
925 This module matches the link-layer packet type.
926 .TP
927 [\fB!\fP] \fB\-\-pkt\-type\fP {\fBunicast\fP|\fBbroadcast\fP|\fBmulticast\fP}
928 .SS policy
929 This modules matches the policy used by IPsec for handling a packet.
930 .TP
931 \fB\-\-dir\fP {\fBin\fP|\fBout\fP}
932 Used to select whether to match the policy used for decapsulation or the
933 policy that will be used for encapsulation.
934 .B in
935 is valid in the
936 .B PREROUTING, INPUT and FORWARD
937 chains,
938 .B out
939 is valid in the
940 .B POSTROUTING, OUTPUT and FORWARD
941 chains.
942 .TP
943 \fB\-\-pol\fP {\fBnone\fP|\fBipsec\fP}
944 Matches if the packet is subject to IPsec processing. \fB\-\-pol none\fP
945 cannot be combined with \fB\-\-strict\fP.
946 .TP
947 \fB\-\-strict\fP
948 Selects whether to match the exact policy or match if any rule of
949 the policy matches the given policy.
950 .PP
951 For each policy element that is to be described, one can use one or more of
952 the following options. When \fB\-\-strict\fP is in effect, at least one must be
953 used per element.
954 .TP
955 [\fB!\fP] \fB\-\-reqid\fP \fIid\fP
956 Matches the reqid of the policy rule. The reqid can be specified with
957 .B setkey(8)
958 using
959 .B unique:id
960 as level.
961 .TP
962 [\fB!\fP] \fB\-\-spi\fP \fIspi\fP
963 Matches the SPI of the SA.
964 .TP
965 [\fB!\fP] \fB\-\-proto\fP {\fBah\fP|\fBesp\fP|\fBipcomp\fP}
966 Matches the encapsulation protocol.
967 .TP
968 [\fB!\fP] \fB\-\-mode\fP {\fBtunnel\fP|\fBtransport\fP}
969 Matches the encapsulation mode.
970 .TP
971 [\fB!\fP] \fB\-\-tunnel\-src\fP \fIaddr\fP[\fB/\fP\fImask\fP]
972 Matches the source end-point address of a tunnel mode SA.
973 Only valid with \fB\-\-mode tunnel\fP.
974 .TP
975 [\fB!\fP] \fB\-\-tunnel\-dst\fP \fIaddr\fP[\fB/\fP\fImask\fP]
976 Matches the destination end-point address of a tunnel mode SA.
977 Only valid with \fB\-\-mode tunnel\fP.
978 .TP
979 \fB\-\-next\fP
980 Start the next element in the policy specification. Can only be used with
981 \fB\-\-strict\fP.
982 .SS quota
983 Implements network quotas by decrementing a byte counter with each
984 packet. The condition matches until the byte counter reaches zero. Behavior
985 is reversed with negation (i.e. the condition does not match until the
986 byte counter reaches zero).
987 .TP
988 [\fB!\fP] \fB\-\-quota\fP \fIbytes\fP
989 The quota in bytes.
990 .SS rateest
991 The rate estimator can match on estimated rates as collected by the RATEEST
992 target. It supports matching on absolute bps/pps values, comparing two rate
993 estimators and matching on the difference between two rate estimators.
994 .PP
995 For a better understanding of the available options, these are all possible
996 combinations:
997 .\" * Absolute:
998 .IP \(bu 4
999 \fBrateest\fP \fIoperator\fP \fBrateest-bps\fP
1000 .IP \(bu 4
1001 \fBrateest\fP \fIoperator\fP \fBrateest-pps\fP
1002 .\" * Absolute + Delta:
1003 .IP \(bu 4
1004 (\fBrateest\fP minus \fBrateest-bps1\fP) \fIoperator\fP \fBrateest-bps2\fP
1005 .IP \(bu 4
1006 (\fBrateest\fP minus \fBrateest-pps1\fP) \fIoperator\fP \fBrateest-pps2\fP
1007 .\" * Relative:
1008 .IP \(bu 4
1009 \fBrateest1\fP \fIoperator\fP \fBrateest2\fP \fBrateest-bps\fP(without rate!)
1010 .IP \(bu 4
1011 \fBrateest1\fP \fIoperator\fP \fBrateest2\fP \fBrateest-pps\fP(without rate!)
1012 .\" * Relative + Delta:
1013 .IP \(bu 4
1014 (\fBrateest1\fP minus \fBrateest-bps1\fP) \fIoperator\fP
1015 (\fBrateest2\fP minus \fBrateest-bps2\fP)
1016 .IP \(bu 4
1017 (\fBrateest1\fP minus \fBrateest-pps1\fP) \fIoperator\fP
1018 (\fBrateest2\fP minus \fBrateest-pps2\fP)
1019 .TP
1020 \fB\-\-rateest\-delta\fP
1021 For each estimator (either absolute or relative mode), calculate the difference
1022 between the estimator-determined flow rate and the static value chosen with the
1023 BPS/PPS options. If the flow rate is higher than the specified BPS/PPS, 0 will
1024 be used instead of a negative value. In other words, "max(0, rateest#_rate -
1025 rateest#_bps)" is used.
1026 .TP
1027 [\fB!\fP] \fB\-\-rateest\-lt\fP
1028 Match if rate is less than given rate/estimator.
1029 .TP
1030 [\fB!\fP] \fB\-\-rateest\-gt\fP
1031 Match if rate is greater than given rate/estimator.
1032 .TP
1033 [\fB!\fP] \fB\-\-rateest\-eq\fP
1034 Match if rate is equal to given rate/estimator.
1035 .PP
1036 In the so-called "absolute mode", only one rate estimator is used and compared
1037 against a static value, while in "relative mode", two rate estimators are
1038 compared against another.
1039 .TP
1040 \fB\-\-rateest\fP \fIname\fP
1041 Name of the one rate estimator for absolute mode.
1042 .TP
1043 \fB\-\-rateest1\fP \fIname\fP
1044 .TP
1045 \fB\-\-rateest2\fP \fIname\fP
1046 The names of the two rate estimators for relative mode.
1047 .TP
1048 \fB\-\-rateest\-bps\fP [\fIvalue\fP]
1049 .TP
1050 \fB\-\-rateest\-pps\fP [\fIvalue\fP]
1051 .TP
1052 \fB\-\-rateest\-bps1\fP [\fIvalue\fP]
1053 .TP
1054 \fB\-\-rateest\-bps2\fP [\fIvalue\fP]
1055 .TP
1056 \fB\-\-rateest\-pps1\fP [\fIvalue\fP]
1057 .TP
1058 \fB\-\-rateest\-pps2\fP [\fIvalue\fP]
1059 Compare the estimator(s) by bytes or packets per second, and compare against
1060 the chosen value. See the above bullet list for which option is to be used in
1061 which case. A unit suffix may be used - available ones are: bit, [kmgt]bit,
1062 [KMGT]ibit, Bps, [KMGT]Bps, [KMGT]iBps.
1063 .PP
1064 Example: This is what can be used to route outgoing data connections from an
1065 FTP server over two lines based on the available bandwidth at the time the data
1066 connection was started:
1067 .PP
1068 # Estimate outgoing rates
1069 .PP
1070 iptables \-t mangle \-A POSTROUTING \-o eth0 \-j RATEEST \-\-rateest\-name eth0
1071 \-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s
1072 .PP
1073 iptables \-t mangle \-A POSTROUTING \-o ppp0 \-j RATEEST \-\-rateest\-name ppp0
1074 \-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s
1075 .PP
1076 # Mark based on available bandwidth
1077 .PP
1078 iptables \-t mangle \-A balance \-m conntrack \-\-ctstate NEW \-m helper \-\-helper ftp
1079 \-m rateest \-\-rateest\-delta \-\-rateest1 eth0 \-\-rateest\-bps1 2.5mbit \-\-rateest\-gt
1080 \-\-rateest2 ppp0 \-\-rateest\-bps2 2mbit \-j CONNMARK \-\-set\-mark 1
1081 .PP
1082 iptables \-t mangle \-A balance \-m conntrack \-\-ctstate NEW \-m helper \-\-helper ftp
1083 \-m rateest \-\-rateest\-delta \-\-rateest1 ppp0 \-\-rateest\-bps1 2mbit \-\-rateest\-gt
1084 \-\-rateest2 eth0 \-\-rateest\-bps2 2.5mbit \-j CONNMARK \-\-set\-mark 2
1085 .PP
1086 iptables \-t mangle \-A balance \-j CONNMARK \-\-restore\-mark
1087 .SS realm (IPv4-specific)
1088 This matches the routing realm.  Routing realms are used in complex routing
1089 setups involving dynamic routing protocols like BGP.
1090 .TP
1091 [\fB!\fP] \fB\-\-realm\fP \fIvalue\fP[\fB/\fP\fImask\fP]
1092 Matches a given realm number (and optionally mask). If not a number, value
1093 can be a named realm from /etc/iproute2/rt_realms (mask can not be used in
1094 that case).
1095 .SS recent
1096 Allows you to dynamically create a list of IP addresses and then match against
1097 that list in a few different ways.
1098 .PP
1099 For example, you can create a "badguy" list out of people attempting to connect
1100 to port 139 on your firewall and then DROP all future packets from them without
1101 considering them.
1102 .PP
1103 \fB\-\-set\fP, \fB\-\-rcheck\fP, \fB\-\-update\fP and \fB\-\-remove\fP are
1104 mutually exclusive.
1105 .TP
1106 \fB\-\-name\fP \fIname\fP
1107 Specify the list to use for the commands. If no name is given then
1108 \fBDEFAULT\fP will be used.
1109 .TP
1110 [\fB!\fP] \fB\-\-set\fP
1111 This will add the source address of the packet to the list. If the source
1112 address is already in the list, this will update the existing entry. This will
1113 always return success (or failure if \fB!\fP is passed in).
1114 .TP
1115 \fB\-\-rsource\fP
1116 Match/save the source address of each packet in the recent list table. This
1117 is the default.
1118 .TP
1119 \fB\-\-rdest\fP
1120 Match/save the destination address of each packet in the recent list table.
1121 .TP
1122 \fB\-\-mask\fP \fInetmask\fP
1123 Netmask that will be applied to this recent list.
1124 .TP
1125 [\fB!\fP] \fB\-\-rcheck\fP
1126 Check if the source address of the packet is currently in the list.
1127 .TP
1128 [\fB!\fP] \fB\-\-update\fP
1129 Like \fB\-\-rcheck\fP, except it will update the "last seen" timestamp if it
1130 matches.
1131 .TP
1132 [\fB!\fP] \fB\-\-remove\fP
1133 Check if the source address of the packet is currently in the list and if so
1134 that address will be removed from the list and the rule will return true. If
1135 the address is not found, false is returned.
1136 .TP
1137 \fB\-\-seconds\fP \fIseconds\fP
1138 This option must be used in conjunction with one of \fB\-\-rcheck\fP or
1139 \fB\-\-update\fP. When used, this will narrow the match to only happen when the
1140 address is in the list and was seen within the last given number of seconds.
1141 .TP
1142 \fB\-\-reap\fP
1143 This option can only be used in conjunction with \fB\-\-seconds\fP.
1144 When used, this will cause entries older than the last given number of seconds
1145 to be purged.
1146 .TP
1147 \fB\-\-hitcount\fP \fIhits\fP
1148 This option must be used in conjunction with one of \fB\-\-rcheck\fP or
1149 \fB\-\-update\fP. When used, this will narrow the match to only happen when the
1150 address is in the list and packets had been received greater than or equal to
1151 the given value. This option may be used along with \fB\-\-seconds\fP to create
1152 an even narrower match requiring a certain number of hits within a specific
1153 time frame. The maximum value for the hitcount parameter is given by the
1154 "ip_pkt_list_tot" parameter of the xt_recent kernel module. Exceeding this
1155 value on the command line will cause the rule to be rejected.
1156 .TP
1157 \fB\-\-rttl\fP
1158 This option may only be used in conjunction with one of \fB\-\-rcheck\fP or
1159 \fB\-\-update\fP. When used, this will narrow the match to only happen when the
1160 address is in the list and the TTL of the current packet matches that of the
1161 packet which hit the \fB\-\-set\fP rule. This may be useful if you have problems
1162 with people faking their source address in order to DoS you via this module by
1163 disallowing others access to your site by sending bogus packets to you.
1164 .PP
1165 Examples:
1166 .IP
1167 iptables \-A FORWARD \-m recent \-\-name badguy \-\-rcheck \-\-seconds 60 \-j DROP
1168 .IP
1169 iptables \-A FORWARD \-p tcp \-i eth0 \-\-dport 139 \-m recent \-\-name badguy \-\-set \-j DROP
1170 .PP
1171 \fB/proc/net/xt_recent/*\fP are the current lists of addresses and information
1172 about each entry of each list.
1173 .PP
1174 Each file in \fB/proc/net/xt_recent/\fP can be read from to see the current
1175 list or written two using the following commands to modify the list:
1176 .TP
1177 \fBecho +\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP
1178 to add \fIaddr\fP to the DEFAULT list
1179 .TP
1180 \fBecho \-\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP
1181 to remove \fIaddr\fP from the DEFAULT list
1182 .TP
1183 \fBecho / >/proc/net/xt_recent/DEFAULT\fP
1184 to flush the DEFAULT list (remove all entries).
1185 .PP
1186 The module itself accepts parameters, defaults shown:
1187 .TP
1188 \fBip_list_tot\fP=\fI100\fP
1189 Number of addresses remembered per table.
1190 .TP
1191 \fBip_pkt_list_tot\fP=\fI20\fP
1192 Number of packets per address remembered.
1193 .TP
1194 \fBip_list_hash_size\fP=\fI0\fP
1195 Hash table size. 0 means to calculate it based on ip_list_tot, default: 512.
1196 .TP
1197 \fBip_list_perms\fP=\fI0644\fP
1198 Permissions for /proc/net/xt_recent/* files.
1199 .TP
1200 \fBip_list_uid\fP=\fI0\fP
1201 Numerical UID for ownership of /proc/net/xt_recent/* files.
1202 .TP
1203 \fBip_list_gid\fP=\fI0\fP
1204 Numerical GID for ownership of /proc/net/xt_recent/* files.
1205 .SS rpfilter
1206 Performs a reverse path filter test on a packet.
1207 If a reply to the packet would be sent via the same interface
1208 that the packet arrived on, the packet will match.
1209 Note that, unlike the in-kernel rp_filter, packets protected
1210 by IPSec are not treated specially.  Combine this match with
1211 the policy match if you want this.
1212 Also, packets arriving via the loopback interface are always permitted.
1213 This match can only be used in the PREROUTING chain of the raw or mangle table.
1214 .TP
1215 \fB\-\-loose\fP
1216 Used to specifiy that the reverse path filter test should match
1217 even if the selected output device is not the expected one.
1218 .TP
1219 \fB\-\-validmark\fP
1220 Also use the packets' nfmark value when performing the reverse path route lookup.
1221 .TP
1222 \fB\-\-accept\-local\fP
1223 This will permit packets arriving from the network with a source address that is also
1224 assigned to the local machine.
1225 .TP
1226 \fB\-\-invert\fP
1227 This will invert the sense of the match.  Instead of matching packets that passed the
1228 reverse path filter test, match those that have failed it.
1229 .PP
1230 Example to log and drop packets failing the reverse path filter test:
1231
1232 iptables \-t raw \-N RPFILTER
1233
1234 iptables \-t raw \-A RPFILTER \-m rpfilter \-j RETURN
1235
1236 iptables \-t raw \-A RPFILTER \-m limit \-\-limit 10/minute \-j NFLOG \-\-nflog\-prefix "rpfilter drop"
1237
1238 iptables \-t raw \-A RPFILTER \-j DROP
1239
1240 iptables \-t raw \-A PREROUTING \-j RPFILTER
1241
1242 Example to drop failed packets, without logging:
1243
1244 iptables \-t raw \-A RPFILTER \-m rpfilter \-\-invert \-j DROP
1245 .SS rt (IPv6-specific)
1246 Match on IPv6 routing header
1247 .TP
1248 [\fB!\fP] \fB\-\-rt\-type\fP \fItype\fP
1249 Match the type (numeric).
1250 .TP
1251 [\fB!\fP] \fB\-\-rt\-segsleft\fP \fInum\fP[\fB:\fP\fInum\fP]
1252 Match the `segments left' field (range).
1253 .TP
1254 [\fB!\fP] \fB\-\-rt\-len\fP \fIlength\fP
1255 Match the length of this header.
1256 .TP
1257 \fB\-\-rt\-0\-res\fP
1258 Match the reserved field, too (type=0)
1259 .TP
1260 \fB\-\-rt\-0\-addrs\fP \fIaddr\fP[\fB,\fP\fIaddr\fP...]
1261 Match type=0 addresses (list).
1262 .TP
1263 \fB\-\-rt\-0\-not\-strict\fP
1264 List of type=0 addresses is not a strict list.
1265 .SS sctp
1266 .TP
1267 [\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP]
1268 .TP
1269 [\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP]
1270 .TP
1271 [\fB!\fP] \fB\-\-chunk\-types\fP {\fBall\fP|\fBany\fP|\fBonly\fP} \fIchunktype\fP[\fB:\fP\fIflags\fP] [...]
1272 The flag letter in upper case indicates that the flag is to match if set,
1273 in the lower case indicates to match if unset.
1274
1275 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 FORWARD_TSN
1276
1277 chunk type            available flags      
1278 .br
1279 DATA                  I U B E i u b e
1280 .br
1281 ABORT                 T t                 
1282 .br
1283 SHUTDOWN_COMPLETE     T t                 
1284
1285 (lowercase means flag should be "off", uppercase means "on")
1286 .P
1287 Examples:
1288
1289 iptables \-A INPUT \-p sctp \-\-dport 80 \-j DROP
1290
1291 iptables \-A INPUT \-p sctp \-\-chunk\-types any DATA,INIT \-j DROP
1292
1293 iptables \-A INPUT \-p sctp \-\-chunk\-types any DATA:Be \-j ACCEPT
1294 .SS set
1295 This module matches IP sets which can be defined by ipset(8).
1296 .TP
1297 [\fB!\fP] \fB\-\-match\-set\fP \fIsetname\fP \fIflag\fP[\fB,\fP\fIflag\fP]...
1298 where flags are the comma separated list of
1299 .BR "src"
1300 and/or
1301 .BR "dst" 
1302 specifications and there can be no more than six of them. Hence the command
1303 .IP
1304  iptables \-A FORWARD \-m set \-\-match\-set test src,dst
1305 .IP
1306 will match packets, for which (if the set type is ipportmap) the source
1307 address and destination port pair can be found in the specified set. If
1308 the set type of the specified set is single dimension (for example ipmap),
1309 then the command will match packets for which the source address can be
1310 found in the specified set. 
1311 .TP
1312 \fB\-\-return\-nomatch\fP
1313 If the \fB\-\-return\-nomatch\fP option is specified and the set type
1314 supports the \fBnomatch\fP flag, then the matching is reversed: a match
1315 with an element flagged with \fBnomatch\fP returns \fBtrue\fP, while a
1316 match with a plain element returns \fBfalse\fP.
1317 .TP
1318 \fB!\fP \fB\-\-update\-counters\fP
1319 If the \fB\-\-update\-counters\fP flag is negated, then the packet and
1320 byte counters of the matching element in the set won't be updated. Default
1321 the packet and byte counters are updated.
1322 .TP
1323 \fB!\fP \fB\-\-update\-subcounters\fP
1324 If the \fB\-\-update\-subcounters\fP flag is negated, then the packet and
1325 byte counters of the matching element in the member set of a list type of
1326 set won't be updated. Default the packet and byte counters are updated.
1327 .TP
1328 [\fB!\fP] \fB\-\-packets\-eq\fP \fIvalue\fP
1329 If the packet is matched an element in the set, match only if the
1330 packet counter of the element matches the given value too.
1331 .TP
1332 \fB\-\-packets\-lt\fP \fIvalue\fP
1333 If the packet is matched an element in the set, match only if the
1334 packet counter of the element is less than the given value as well.
1335 .TP
1336 \fB\-\-packets\-gt\fP \fIvalue\fP
1337 If the packet is matched an element in the set, match only if the
1338 packet counter of the element is greater than the given value as well.
1339 .TP
1340 [\fB!\fP] \fB\-bytes\-eq\fP \fIvalue\fP
1341 If the packet is matched an element in the set, match only if the
1342 byte counter of the element matches the given value too.
1343 .TP
1344 \fB\-\-bytes\-lt\fP \fIvalue\fP
1345 If the packet is matched an element in the set, match only if the
1346 byte counter of the element is less than the given value as well.
1347 .TP
1348 \fB\-\-bytes\-gt\fP \fIvalue\fP
1349 If the packet is matched an element in the set, match only if the
1350 byte counter of the element is greater than the given value as well.
1351 .PP
1352 The packet and byte counters related options and flags are ignored
1353 when the set was defined without counter support.
1354 .PP
1355 The option \fB\-\-match\-set\fP can be replaced by \fB\-\-set\fP if that does 
1356 not clash with an option of other extensions.
1357 .PP
1358 Use of -m set requires that ipset kernel support is provided, which, for
1359 standard kernels, is the case since Linux 2.6.39.
1360 .SS socket
1361 This matches if an open TCP/UDP socket can be found by doing a socket lookup on the
1362 packet. It matches if there is an established or non\-zero bound listening
1363 socket (possibly with a non\-local address). The lookup is performed using
1364 the \fBpacket\fP tuple of TCP/UDP packets, or the original TCP/UDP header
1365 \fBembedded\fP in an ICMP/ICPMv6 error packet.
1366 .TP
1367 \fB\-\-transparent\fP
1368 Ignore non-transparent sockets.
1369 .TP
1370 \fB\-\-nowildcard\fP
1371 Do not ignore sockets bound to 'any' address.
1372 The socket match won't accept zero\-bound listeners by default, since
1373 then local services could intercept traffic that would otherwise be forwarded.
1374 This option therefore has security implications when used to match traffic being
1375 forwarded to redirect such packets to local machine with policy routing.
1376 When using the socket match to implement fully transparent
1377 proxies bound to non\-local addresses it is recommended to use the \-\-transparent
1378 option instead.
1379 .PP
1380 Example (assuming packets with mark 1 are delivered locally):
1381 .IP
1382 \-t mangle \-A PREROUTING \-m socket \-\-transparent \-j MARK \-\-set\-mark 1
1383 .SS state
1384 The "state" extension is a subset of the "conntrack" module.
1385 "state" allows access to the connection tracking state for this packet.
1386 .TP
1387 [\fB!\fP] \fB\-\-state\fP \fIstate\fP
1388 Where state is a comma separated list of the connection states to match. Only a
1389 subset of the states unterstood by "conntrack" are recognized: \fBINVALID\fP,
1390 \fBESTABLISHED\fP, \fBNEW\fP, \fBRELATED\fP or \fBUNTRACKED\fP. For their
1391 description, see the "conntrack" heading in this manpage.
1392 .SS statistic
1393 This module matches packets based on some statistic condition.
1394 It supports two distinct modes settable with the 
1395 \fB\-\-mode\fP
1396 option.
1397 .PP
1398 Supported options:
1399 .TP
1400 \fB\-\-mode\fP \fImode\fP
1401 Set the matching mode of the matching rule, supported modes are
1402 .B random
1403 and
1404 .B nth. 
1405 .TP
1406 [\fB!\fP] \fB\-\-probability\fP \fIp\fP
1407 Set the probability for a packet to be randomly matched. It only works with the
1408 \fBrandom\fP mode. \fIp\fP must be within 0.0 and 1.0. The supported
1409 granularity is in 1/2147483648th increments.
1410 .TP
1411 [\fB!\fP] \fB\-\-every\fP \fIn\fP
1412 Match one packet every nth packet. It works only with the
1413 .B nth
1414 mode (see also the 
1415 \fB\-\-packet\fP
1416 option).
1417 .TP
1418 \fB\-\-packet\fP \fIp\fP
1419 Set the initial counter value (0 <= p <= n\-1, default 0) for the
1420 .B nth 
1421 mode.
1422 .SS string
1423 This modules matches a given string by using some pattern matching strategy. It requires a linux kernel >= 2.6.14.
1424 .TP
1425 \fB\-\-algo\fP {\fBbm\fP|\fBkmp\fP}
1426 Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morris)
1427 .TP
1428 \fB\-\-from\fP \fIoffset\fP
1429 Set the offset from which it starts looking for any matching. If not passed, default is 0.
1430 .TP
1431 \fB\-\-to\fP \fIoffset\fP
1432 Set the offset up to which should be scanned. That is, byte \fIoffset\fP-1
1433 (counting from 0) is the last one that is scanned.
1434 If not passed, default is the packet size.
1435 .TP
1436 [\fB!\fP] \fB\-\-string\fP \fIpattern\fP
1437 Matches the given pattern.
1438 .TP
1439 [\fB!\fP] \fB\-\-hex\-string\fP \fIpattern\fP
1440 Matches the given pattern in hex notation.
1441 .TP
1442 Examples:
1443 .IP
1444 # The string pattern can be used for simple text characters.
1445 .br
1446 iptables \-A INPUT \-p tcp \-\-dport 80 \-m string \-\-algo bm \-\-string 'GET /index.html' \-j LOG
1447 .IP
1448 # The hex string pattern can be used for non-printable characters, like |0D 0A| or |0D0A|.
1449 .br
1450 iptables \-p udp \-\-dport 53 \-m string \-\-algo bm \-\-from 40 \-\-to 57 \-\-hex\-string '|03|www|09|netfilter|03|org|00|'
1451 .SS tcp
1452 These extensions can be used if `\-\-protocol tcp' is specified. It
1453 provides the following options:
1454 .TP
1455 [\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP]
1456 Source port or port range specification. This can either be a service
1457 name or a port number. An inclusive range can also be specified,
1458 using the format \fIfirst\fP\fB:\fP\fIlast\fP.
1459 If the first port is omitted, "0" is assumed; if the last is omitted,
1460 "65535" is assumed.
1461 If the first port is greater than the second one they will be swapped.
1462 The flag
1463 \fB\-\-sport\fP
1464 is a convenient alias for this option.
1465 .TP
1466 [\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP]
1467 Destination port or port range specification.  The flag
1468 \fB\-\-dport\fP
1469 is a convenient alias for this option.
1470 .TP
1471 [\fB!\fP] \fB\-\-tcp\-flags\fP \fImask\fP \fIcomp\fP
1472 Match when the TCP flags are as specified.  The first argument \fImask\fP is the
1473 flags which we should examine, written as a comma-separated list, and
1474 the second argument \fIcomp\fP is a comma-separated list of flags which must be
1475 set.  Flags are:
1476 .BR "SYN ACK FIN RST URG PSH ALL NONE" .
1477 Hence the command
1478 .nf
1479  iptables \-A FORWARD \-p tcp \-\-tcp\-flags SYN,ACK,FIN,RST SYN
1480 .fi
1481 will only match packets with the SYN flag set, and the ACK, FIN and
1482 RST flags unset.
1483 .TP
1484 [\fB!\fP] \fB\-\-syn\fP
1485 Only match TCP packets with the SYN bit set and the ACK,RST and FIN bits
1486 cleared.  Such packets are used to request TCP connection initiation;
1487 for example, blocking such packets coming in an interface will prevent
1488 incoming TCP connections, but outgoing TCP connections will be
1489 unaffected.
1490 It is equivalent to \fB\-\-tcp\-flags SYN,RST,ACK,FIN SYN\fP.
1491 If the "!" flag precedes the "\-\-syn", the sense of the
1492 option is inverted.
1493 .TP
1494 [\fB!\fP] \fB\-\-tcp\-option\fP \fInumber\fP
1495 Match if TCP option set.
1496 .SS tcpmss
1497 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.
1498 .TP
1499 [\fB!\fP] \fB\-\-mss\fP \fIvalue\fP[\fB:\fP\fIvalue\fP]
1500 Match a given TCP MSS value or range.
1501 .SS time
1502 This matches if the packet arrival time/date is within a given range. All
1503 options are optional, but are ANDed when specified. All times are interpreted
1504 as UTC by default.
1505 .TP
1506 \fB\-\-datestart\fP \fIYYYY\fP[\fB\-\fP\fIMM\fP[\fB\-\fP\fIDD\fP[\fBT\fP\fIhh\fP[\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]]]]]
1507 .TP
1508 \fB\-\-datestop\fP \fIYYYY\fP[\fB\-\fP\fIMM\fP[\fB\-\fP\fIDD\fP[\fBT\fP\fIhh\fP[\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]]]]]
1509 Only match during the given time, which must be in ISO 8601 "T" notation.
1510 The possible time range is 1970-01-01T00:00:00 to 2038-01-19T04:17:07.
1511 .IP
1512 If \-\-datestart or \-\-datestop are not specified, it will default to 1970-01-01
1513 and 2038-01-19, respectively.
1514 .TP
1515 \fB\-\-timestart\fP \fIhh\fP\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]
1516 .TP
1517 \fB\-\-timestop\fP \fIhh\fP\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]
1518 Only match during the given daytime. The possible time range is 00:00:00 to
1519 23:59:59. Leading zeroes are allowed (e.g. "06:03") and correctly interpreted
1520 as base-10.
1521 .TP
1522 [\fB!\fP] \fB\-\-monthdays\fP \fIday\fP[\fB,\fP\fIday\fP...]
1523 Only match on the given days of the month. Possible values are \fB1\fP
1524 to \fB31\fP. Note that specifying \fB31\fP will of course not match
1525 on months which do not have a 31st day; the same goes for 28- or 29-day
1526 February.
1527 .TP
1528 [\fB!\fP] \fB\-\-weekdays\fP \fIday\fP[\fB,\fP\fIday\fP...]
1529 Only match on the given weekdays. Possible values are \fBMon\fP, \fBTue\fP,
1530 \fBWed\fP, \fBThu\fP, \fBFri\fP, \fBSat\fP, \fBSun\fP, or values from \fB1\fP
1531 to \fB7\fP, respectively. You may also use two-character variants (\fBMo\fP,
1532 \fBTu\fP, etc.).
1533 .TP
1534 \fB\-\-contiguous\fP
1535 When \fB\-\-timestop\fP is smaller than \fB\-\-timestart\fP value, match
1536 this as a single time period instead distinct intervals.  See EXAMPLES.
1537 .TP
1538 \fB\-\-kerneltz\fP
1539 Use the kernel timezone instead of UTC to determine whether a packet meets the
1540 time regulations.
1541 .PP
1542 About kernel timezones: Linux keeps the system time in UTC, and always does so.
1543 On boot, system time is initialized from a referential time source. Where this
1544 time source has no timezone information, such as the x86 CMOS RTC, UTC will be
1545 assumed. If the time source is however not in UTC, userspace should provide the
1546 correct system time and timezone to the kernel once it has the information.
1547 .PP
1548 Local time is a feature on top of the (timezone independent) system time. Each
1549 process has its own idea of local time, specified via the TZ environment
1550 variable. The kernel also has its own timezone offset variable. The TZ
1551 userspace environment variable specifies how the UTC-based system time is
1552 displayed, e.g. when you run date(1), or what you see on your desktop clock.
1553 The TZ string may resolve to different offsets at different dates, which is
1554 what enables the automatic time-jumping in userspace. when DST changes. The
1555 kernel's timezone offset variable is used when it has to convert between
1556 non-UTC sources, such as FAT filesystems, to UTC (since the latter is what the
1557 rest of the system uses).
1558 .PP
1559 The caveat with the kernel timezone is that Linux distributions may ignore to
1560 set the kernel timezone, and instead only set the system time. Even if a
1561 particular distribution does set the timezone at boot, it is usually does not
1562 keep the kernel timezone offset - which is what changes on DST - up to date.
1563 ntpd will not touch the kernel timezone, so running it will not resolve the
1564 issue. As such, one may encounter a timezone that is always +0000, or one that
1565 is wrong half of the time of the year. As such, \fBusing \-\-kerneltz is highly
1566 discouraged.\fP
1567 .PP
1568 EXAMPLES. To match on weekends, use:
1569 .IP
1570 \-m time \-\-weekdays Sa,Su
1571 .PP
1572 Or, to match (once) on a national holiday block:
1573 .IP
1574 \-m time \-\-datestart 2007\-12\-24 \-\-datestop 2007\-12\-27
1575 .PP
1576 Since the stop time is actually inclusive, you would need the following stop
1577 time to not match the first second of the new day:
1578 .IP
1579 \-m time \-\-datestart 2007\-01\-01T17:00 \-\-datestop 2007\-01\-01T23:59:59
1580 .PP
1581 During lunch hour:
1582 .IP
1583 \-m time \-\-timestart 12:30 \-\-timestop 13:30
1584 .PP
1585 The fourth Friday in the month:
1586 .IP
1587 \-m time \-\-weekdays Fr \-\-monthdays 22,23,24,25,26,27,28
1588 .PP
1589 (Note that this exploits a certain mathematical property. It is not possible to
1590 say "fourth Thursday OR fourth Friday" in one rule. It is possible with
1591 multiple rules, though.)
1592 .PP
1593 Matching across days might not do what is expected.  For instance,
1594 .IP
1595 \-m time \-\-weekdays Mo \-\-timestart 23:00  \-\-timestop 01:00
1596 Will match Monday, for one hour from midnight to 1 a.m., and then
1597 again for another hour from 23:00 onwards.  If this is unwanted, e.g. if you
1598 would like 'match for two hours from Montay 23:00 onwards' you need to also specify
1599 the \-\-contiguous option in the example above.
1600 .SS tos
1601 This module matches the 8-bit Type of Service field in the IPv4 header (i.e.
1602 including the "Precedence" bits) or the (also 8-bit) Priority field in the IPv6
1603 header.
1604 .TP
1605 [\fB!\fP] \fB\-\-tos\fP \fIvalue\fP[\fB/\fP\fImask\fP]
1606 Matches packets with the given TOS mark value. If a mask is specified, it is
1607 logically ANDed with the TOS mark before the comparison.
1608 .TP
1609 [\fB!\fP] \fB\-\-tos\fP \fIsymbol\fP
1610 You can specify a symbolic name when using the tos match for IPv4. The list of
1611 recognized TOS names can be obtained by calling iptables with \fB\-m tos \-h\fP.
1612 Note that this implies a mask of 0x3F, i.e. all but the ECN bits.
1613 .SS ttl (IPv4-specific)
1614 This module matches the time to live field in the IP header.
1615 .TP
1616 [\fB!\fP] \fB\-\-ttl\-eq\fP \fIttl\fP
1617 Matches the given TTL value.
1618 .TP
1619 \fB\-\-ttl\-gt\fP \fIttl\fP
1620 Matches if TTL is greater than the given TTL value.
1621 .TP
1622 \fB\-\-ttl\-lt\fP \fIttl\fP
1623 Matches if TTL is less than the given TTL value.
1624 .SS u32
1625 U32 tests whether quantities of up to 4 bytes extracted from a packet have
1626 specified values. The specification of what to extract is general enough to
1627 find data at given offsets from tcp headers or payloads.
1628 .TP
1629 [\fB!\fP] \fB\-\-u32\fP \fItests\fP
1630 The argument amounts to a program in a small language described below.
1631 .IP
1632 tests := location "=" value | tests "&&" location "=" value
1633 .IP
1634 value := range | value "," range
1635 .IP
1636 range := number | number ":" number
1637 .PP
1638 a single number, \fIn\fP, is interpreted the same as \fIn:n\fP. \fIn:m\fP is
1639 interpreted as the range of numbers \fB>=n\fP and \fB<=m\fP.
1640 .IP "" 4
1641 location := number | location operator number
1642 .IP "" 4
1643 operator := "&" | "<<" | ">>" | "@"
1644 .PP
1645 The operators \fB&\fP, \fB<<\fP, \fB>>\fP and \fB&&\fP mean the same as in C.
1646 The \fB=\fP is really a set membership operator and the value syntax describes
1647 a set. The \fB@\fP operator is what allows moving to the next header and is
1648 described further below.
1649 .PP
1650 There are currently some artificial implementation limits on the size of the
1651 tests:
1652 .IP "    *"
1653 no more than 10 of "\fB=\fP" (and 9 "\fB&&\fP"s) in the u32 argument
1654 .IP "    *"
1655 no more than 10 ranges (and 9 commas) per value
1656 .IP "    *"
1657 no more than 10 numbers (and 9 operators) per location
1658 .PP
1659 To describe the meaning of location, imagine the following machine that
1660 interprets it. There are three registers:
1661 .IP
1662 A is of type \fBchar *\fP, initially the address of the IP header
1663 .IP
1664 B and C are unsigned 32 bit integers, initially zero
1665 .PP
1666 The instructions are:
1667 .IP
1668 number B = number;
1669 .IP
1670 C = (*(A+B)<<24) + (*(A+B+1)<<16) + (*(A+B+2)<<8) + *(A+B+3)
1671 .IP
1672 &number C = C & number
1673 .IP
1674 << number C = C << number
1675 .IP
1676 >> number C = C >> number
1677 .IP
1678 @number A = A + C; then do the instruction number
1679 .PP
1680 Any access of memory outside [skb\->data,skb\->end] causes the match to fail.
1681 Otherwise the result of the computation is the final value of C.
1682 .PP
1683 Whitespace is allowed but not required in the tests. However, the characters
1684 that do occur there are likely to require shell quoting, so it is a good idea
1685 to enclose the arguments in quotes.
1686 .PP
1687 Example:
1688 .IP
1689 match IP packets with total length >= 256
1690 .IP
1691 The IP header contains a total length field in bytes 2-3.
1692 .IP
1693 \-\-u32 "\fB0 & 0xFFFF = 0x100:0xFFFF\fP"
1694 .IP
1695 read bytes 0-3
1696 .IP
1697 AND that with 0xFFFF (giving bytes 2-3), and test whether that is in the range
1698 [0x100:0xFFFF]
1699 .PP
1700 Example: (more realistic, hence more complicated)
1701 .IP
1702 match ICMP packets with icmp type 0
1703 .IP
1704 First test that it is an ICMP packet, true iff byte 9 (protocol) = 1
1705 .IP
1706 \-\-u32 "\fB6 & 0xFF = 1 &&\fP ...
1707 .IP
1708 read bytes 6-9, use \fB&\fP to throw away bytes 6-8 and compare the result to
1709 1. Next test that it is not a fragment. (If so, it might be part of such a
1710 packet but we cannot always tell.) N.B.: This test is generally needed if you
1711 want to match anything beyond the IP header. The last 6 bits of byte 6 and all
1712 of byte 7 are 0 iff this is a complete packet (not a fragment). Alternatively,
1713 you can allow first fragments by only testing the last 5 bits of byte 6.
1714 .IP
1715  ... \fB4 & 0x3FFF = 0 &&\fP ...
1716 .IP
1717 Last test: the first byte past the IP header (the type) is 0. This is where we
1718 have to use the @syntax. The length of the IP header (IHL) in 32 bit words is
1719 stored in the right half of byte 0 of the IP header itself.
1720 .IP
1721  ... \fB0 >> 22 & 0x3C @ 0 >> 24 = 0\fP"
1722 .IP
1723 The first 0 means read bytes 0-3, \fB>>22\fP means shift that 22 bits to the
1724 right. Shifting 24 bits would give the first byte, so only 22 bits is four
1725 times that plus a few more bits. \fB&3C\fP then eliminates the two extra bits
1726 on the right and the first four bits of the first byte. For instance, if IHL=5,
1727 then the IP header is 20 (4 x 5) bytes long. In this case, bytes 0-1 are (in
1728 binary) xxxx0101 yyzzzzzz, \fB>>22\fP gives the 10 bit value xxxx0101yy and
1729 \fB&3C\fP gives 010100. \fB@\fP means to use this number as a new offset into
1730 the packet, and read four bytes starting from there. This is the first 4 bytes
1731 of the ICMP payload, of which byte 0 is the ICMP type. Therefore, we simply
1732 shift the value 24 to the right to throw out all but the first byte and compare
1733 the result with 0.
1734 .PP
1735 Example:
1736 .IP
1737 TCP payload bytes 8-12 is any of 1, 2, 5 or 8
1738 .IP
1739 First we test that the packet is a tcp packet (similar to ICMP).
1740 .IP
1741 \-\-u32 "\fB6 & 0xFF = 6 &&\fP ...
1742 .IP
1743 Next, test that it is not a fragment (same as above).
1744 .IP
1745  ... \fB0 >> 22 & 0x3C @ 12 >> 26 & 0x3C @ 8 = 1,2,5,8\fP"
1746 .IP
1747 \fB0>>22&3C\fP as above computes the number of bytes in the IP header. \fB@\fP
1748 makes this the new offset into the packet, which is the start of the TCP
1749 header. The length of the TCP header (again in 32 bit words) is the left half
1750 of byte 12 of the TCP header. The \fB12>>26&3C\fP computes this length in bytes
1751 (similar to the IP header before). "@" makes this the new offset, which is the
1752 start of the TCP payload. Finally, 8 reads bytes 8-12 of the payload and
1753 \fB=\fP checks whether the result is any of 1, 2, 5 or 8.
1754 .SS udp
1755 These extensions can be used if `\-\-protocol udp' is specified. It
1756 provides the following options:
1757 .TP
1758 [\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP]
1759 Source port or port range specification.
1760 See the description of the
1761 \fB\-\-source\-port\fP
1762 option of the TCP extension for details.
1763 .TP
1764 [\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP]
1765 Destination port or port range specification.
1766 See the description of the
1767 \fB\-\-destination\-port\fP
1768 option of the TCP extension for details.
1769 .SS unclean (IPv4-specific)
1770 This module takes no options, but attempts to match packets which seem
1771 malformed or unusual.  This is regarded as experimental.
1772 .SH TARGET EXTENSIONS
1773 iptables can use extended target modules: the following are included
1774 in the standard distribution.
1775 .\" @TARGET@
1776 .SS AUDIT
1777 This target allows to create audit records for packets hitting the target.
1778 It can be used to record accepted, dropped, and rejected packets. See
1779 auditd(8) for additional details.
1780 .TP
1781 \fB\-\-type\fP {\fBaccept\fP|\fBdrop\fP|\fBreject\fP}
1782 Set type of audit record.
1783 .PP
1784 Example:
1785 .IP
1786 iptables \-N AUDIT_DROP
1787 .IP
1788 iptables \-A AUDIT_DROP \-j AUDIT \-\-type drop
1789 .IP
1790 iptables \-A AUDIT_DROP \-j DROP
1791 .SS CHECKSUM
1792 This target allows to selectively work around broken/old applications.
1793 It can only be used in the mangle table.
1794 .TP
1795 \fB\-\-checksum\-fill\fP
1796 Compute and fill in the checksum in a packet that lacks a checksum.
1797 This is particularly useful, if you need to work around old applications
1798 such as dhcp clients, that do not work well with checksum offloads,
1799 but don't want to disable checksum offload in your device.
1800 .SS CLASSIFY
1801 This module allows you to set the skb\->priority value (and thus classify the packet into a specific CBQ class).
1802 .TP
1803 \fB\-\-set\-class\fP \fImajor\fP\fB:\fP\fIminor\fP
1804 Set the major and minor class value. The values are always interpreted as
1805 hexadecimal even if no 0x prefix is given.
1806 .SS CLUSTERIP (IPv4-specific)
1807 This module allows you to configure a simple cluster of nodes that share
1808 a certain IP and MAC address without an explicit load balancer in front of
1809 them.  Connections are statically distributed between the nodes in this
1810 cluster.
1811 .TP
1812 \fB\-\-new\fP
1813 Create a new ClusterIP.  You always have to set this on the first rule
1814 for a given ClusterIP.
1815 .TP
1816 \fB\-\-hashmode\fP \fImode\fP
1817 Specify the hashing mode.  Has to be one of
1818 \fBsourceip\fP, \fBsourceip\-sourceport\fP, \fBsourceip\-sourceport\-destport\fP.
1819 .TP
1820 \fB\-\-clustermac\fP \fImac\fP
1821 Specify the ClusterIP MAC address. Has to be a link\-layer multicast address
1822 .TP
1823 \fB\-\-total\-nodes\fP \fInum\fP
1824 Number of total nodes within this cluster.
1825 .TP
1826 \fB\-\-local\-node\fP \fInum\fP
1827 Local node number within this cluster.
1828 .TP
1829 \fB\-\-hash\-init\fP \fIrnd\fP
1830 Specify the random seed used for hash initialization.
1831 .SS CONNMARK
1832 This module sets the netfilter mark value associated with a connection. The
1833 mark is 32 bits wide.
1834 .TP
1835 \fB\-\-set\-xmark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
1836 Zero out the bits given by \fImask\fP and XOR \fIvalue\fP into the ctmark.
1837 .TP
1838 \fB\-\-save\-mark\fP [\fB\-\-nfmask\fP \fInfmask\fP] [\fB\-\-ctmask\fP \fIctmask\fP]
1839 Copy the packet mark (nfmark) to the connection mark (ctmark) using the given
1840 masks. The new nfmark value is determined as follows:
1841 .IP
1842 ctmark = (ctmark & ~ctmask) ^ (nfmark & nfmask)
1843 .IP
1844 i.e. \fIctmask\fP defines what bits to clear and \fInfmask\fP what bits of the
1845 nfmark to XOR into the ctmark. \fIctmask\fP and \fInfmask\fP default to
1846 0xFFFFFFFF.
1847 .TP
1848 \fB\-\-restore\-mark\fP [\fB\-\-nfmask\fP \fInfmask\fP] [\fB\-\-ctmask\fP \fIctmask\fP]
1849 Copy the connection mark (ctmark) to the packet mark (nfmark) using the given
1850 masks. The new ctmark value is determined as follows:
1851 .IP
1852 nfmark = (nfmark & ~\fInfmask\fP) ^ (ctmark & \fIctmask\fP);
1853 .IP
1854 i.e. \fInfmask\fP defines what bits to clear and \fIctmask\fP what bits of the
1855 ctmark to XOR into the nfmark. \fIctmask\fP and \fInfmask\fP default to
1856 0xFFFFFFFF.
1857 .IP
1858 \fB\-\-restore\-mark\fP is only valid in the \fBmangle\fP table.
1859 .PP
1860 The following mnemonics are available for \fB\-\-set\-xmark\fP:
1861 .TP
1862 \fB\-\-and\-mark\fP \fIbits\fP
1863 Binary AND the ctmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark
1864 0/\fP\fIinvbits\fP, where \fIinvbits\fP is the binary negation of \fIbits\fP.)
1865 .TP
1866 \fB\-\-or\-mark\fP \fIbits\fP
1867 Binary OR the ctmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark\fP
1868 \fIbits\fP\fB/\fP\fIbits\fP.)
1869 .TP
1870 \fB\-\-xor\-mark\fP \fIbits\fP
1871 Binary XOR the ctmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark\fP
1872 \fIbits\fP\fB/0\fP.)
1873 .TP
1874 \fB\-\-set\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
1875 Set the connection mark. If a mask is specified then only those bits set in the
1876 mask are modified.
1877 .TP
1878 \fB\-\-save\-mark\fP [\fB\-\-mask\fP \fImask\fP]
1879 Copy the nfmark to the ctmark. If a mask is specified, only those bits are
1880 copied.
1881 .TP
1882 \fB\-\-restore\-mark\fP [\fB\-\-mask\fP \fImask\fP]
1883 Copy the ctmark to the nfmark. If a mask is specified, only those bits are
1884 copied. This is only valid in the \fBmangle\fP table.
1885 .SS CONNSECMARK
1886 This module copies security markings from packets to connections
1887 (if unlabeled), and from connections back to packets (also only
1888 if unlabeled).  Typically used in conjunction with SECMARK, it is
1889 valid in the
1890 .B security
1891 table (for backwards compatibility with older kernels, it is also
1892 valid in the
1893 .B mangle
1894 table).
1895 .TP
1896 \fB\-\-save\fP
1897 If the packet has a security marking, copy it to the connection
1898 if the connection is not marked.
1899 .TP
1900 \fB\-\-restore\fP
1901 If the packet does not have a security marking, and the connection
1902 does, copy the security marking from the connection to the packet.
1903
1904 .SS CT
1905 The CT target allows to set parameters for a packet or its associated
1906 connection. The target attaches a "template" connection tracking entry to
1907 the packet, which is then used by the conntrack core when initializing
1908 a new ct entry. This target is thus only valid in the "raw" table.
1909 .TP
1910 \fB\-\-notrack\fP
1911 Disables connection tracking for this packet.
1912 .TP
1913 \fB\-\-helper\fP \fIname\fP
1914 Use the helper identified by \fIname\fP for the connection. This is more
1915 flexible than loading the conntrack helper modules with preset ports.
1916 .TP
1917 \fB\-\-ctevents\fP \fIevent\fP[\fB,\fP...]
1918 Only generate the specified conntrack events for this connection. Possible
1919 event types are: \fBnew\fP, \fBrelated\fP, \fBdestroy\fP, \fBreply\fP,
1920 \fBassured\fP, \fBprotoinfo\fP, \fBhelper\fP, \fBmark\fP (this refers to
1921 the ctmark, not nfmark), \fBnatseqinfo\fP, \fBsecmark\fP (ctsecmark).
1922 .TP
1923 \fB\-\-expevents\fP \fIevent\fP[\fB,\fP...]
1924 Only generate the specified expectation events for this connection.
1925 Possible event types are: \fBnew\fP.
1926 .TP
1927 \fB\-\-zone\fP \fIid\fP
1928 Assign this packet to zone \fIid\fP and only have lookups done in that zone.
1929 By default, packets have zone 0.
1930 .TP
1931 \fB\-\-timeout\fP \fIname\fP
1932 Use the timeout policy identified by \fIname\fP for the connection. This is
1933 provides more flexible timeout policy definition than global timeout values
1934 available at /proc/sys/net/netfilter/nf_conntrack_*_timeout_*.
1935 .SS DNAT
1936 This target is only valid in the
1937 .B nat
1938 table, in the
1939 .B PREROUTING
1940 and
1941 .B OUTPUT
1942 chains, and user-defined chains which are only called from those
1943 chains.  It specifies that the destination address of the packet
1944 should be modified (and all future packets in this connection will
1945 also be mangled), and rules should cease being examined.  It takes the
1946 following options:
1947 .TP
1948 \fB\-\-to\-destination\fP [\fIipaddr\fP[\fB\-\fP\fIipaddr\fP]][\fB:\fP\fIport\fP[\fB\-\fP\fIport\fP]]
1949 which can specify a single new destination IP address, an inclusive
1950 range of IP addresses. Optionally a port range,
1951 if the rule also specifies one of the following protocols:
1952 \fBtcp\fP, \fBudp\fP, \fBdccp\fP or \fBsctp\fP.
1953 If no port range is specified, then the destination port will never be
1954 modified. If no IP address is specified then only the destination port
1955 will be modified.
1956 In Kernels up to 2.6.10 you can add several \-\-to\-destination options. For
1957 those kernels, if you specify more than one destination address, either via an
1958 address range or multiple \-\-to\-destination options, a simple round-robin (one
1959 after another in cycle) load balancing takes place between these addresses.
1960 Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to multiple ranges
1961 anymore.
1962 .TP
1963 \fB\-\-random\fP
1964 If option
1965 \fB\-\-random\fP
1966 is used then port mapping will be randomized (kernel >= 2.6.22).
1967 .TP
1968 \fB\-\-persistent\fP
1969 Gives a client the same source-/destination-address for each connection.
1970 This supersedes the SAME target. Support for persistent mappings is available
1971 from 2.6.29-rc2.
1972 .TP
1973 IPv6 support available since Linux kernels >= 3.7.
1974 .SS DNPT (IPv6-specific)
1975 Provides stateless destination IPv6-to-IPv6 Network Prefix Translation (as
1976 described by RFC 6296).
1977 .PP
1978 You have to use this target in the
1979 .B mangle
1980 table, not in the
1981 .B nat
1982 table. It takes the following options:
1983 .TP
1984 \fB\-\-src\-pfx\fP [\fIprefix/\fP\fIlength]
1985 Set source prefix that you want to translate and length
1986 .TP
1987 \fB\-\-dst\-pfx\fP [\fIprefix/\fP\fIlength]
1988 Set destination prefix that you want to use in the translation and length
1989 .PP
1990 You have to use the SNPT target to undo the translation. Example:
1991 .IP
1992 ip6tables \-t mangle \-I POSTROUTING \-s fd00::/64 \! \-o vboxnet0
1993 \-j SNPT \-\-src-pfx fd00::/64 \-\-dst-pfx 2001:e20:2000:40f::/64
1994 .IP
1995 ip6tables \-t mangle \-I PREROUTING \-i wlan0 \-d 2001:e20:2000:40f::/64
1996 \-j DNPT \-\-src-pfx 2001:e20:2000:40f::/64 \-\-dst-pfx fd00::/64
1997 .PP
1998 You may need to enable IPv6 neighbor proxy:
1999 .IP
2000 sysctl -w net.ipv6.conf.all.proxy_ndp=1
2001 .PP
2002 You also have to use the
2003 .B NOTRACK
2004 target to disable connection tracking for translated flows.
2005 .SS DSCP
2006 This target allows to alter the value of the DSCP bits within the TOS
2007 header of the IPv4 packet.  As this manipulates a packet, it can only
2008 be used in the mangle table.
2009 .TP
2010 \fB\-\-set\-dscp\fP \fIvalue\fP
2011 Set the DSCP field to a numerical value (can be decimal or hex)
2012 .TP
2013 \fB\-\-set\-dscp\-class\fP \fIclass\fP
2014 Set the DSCP field to a DiffServ class.
2015 .SS ECN (IPv4-specific)
2016 This target allows to selectively work around known ECN blackholes.
2017 It can only be used in the mangle table.
2018 .TP
2019 \fB\-\-ecn\-tcp\-remove\fP
2020 Remove all ECN bits from the TCP header.  Of course, it can only be used
2021 in conjunction with
2022 \fB\-p tcp\fP.
2023 .SS HL (IPv6-specific)
2024 This is used to modify the Hop Limit field in IPv6 header. The Hop Limit field
2025 is similar to what is known as TTL value in IPv4.  Setting or incrementing the
2026 Hop Limit field can potentially be very dangerous, so it should be avoided at
2027 any cost. This target is only valid in
2028 .B mangle
2029 table.
2030 .PP
2031 .B Don't ever set or increment the value on packets that leave your local network!
2032 .TP
2033 \fB\-\-hl\-set\fP \fIvalue\fP
2034 Set the Hop Limit to `value'.
2035 .TP
2036 \fB\-\-hl\-dec\fP \fIvalue\fP
2037 Decrement the Hop Limit `value' times.
2038 .TP
2039 \fB\-\-hl\-inc\fP \fIvalue\fP
2040 Increment the Hop Limit `value' times.
2041 .SS HMARK
2042 Like MARK, i.e. set the fwmark, but the mark is calculated from hashing
2043 packet selector at choice. You have also to specify the mark range and,
2044 optionally, the offset to start from. ICMP error messages are inspected
2045 and used to calculate the hashing.
2046 .PP
2047 Existing options are:
2048 .TP
2049 \fB\-\-hmark\-tuple\fP tuple\fI\fP
2050 Possible tuple members are:
2051 .B src
2052 meaning source address (IPv4, IPv6 address),
2053 .B dst
2054 meaning destination address (IPv4, IPv6 address),
2055 .B sport
2056 meaning source port (TCP, UDP, UDPlite, SCTP, DCCP),
2057 .B dport
2058 meaning destination port (TCP, UDP, UDPlite, SCTP, DCCP),
2059 .B spi
2060 meaning Security Parameter Index (AH, ESP), and
2061 .B ct
2062 meaning the usage of the conntrack tuple instead of the packet selectors.
2063 .TP
2064 \fB\-\-hmark\-mod\fP \fIvalue (must be > 0)\fP
2065 Modulus for hash calculation (to limit the range of possible marks)
2066 .TP
2067 \fB\-\-hmark\-offset\fP \fIvalue\fP
2068 Offset to start marks from.
2069 .TP
2070 For advanced usage, instead of using \-\-hmark\-tuple, you can specify custom
2071 prefixes and masks:
2072 .TP
2073 \fB\-\-hmark\-src\-prefix\fP \fIcidr\fP
2074 The source address mask in CIDR notation.
2075 .TP
2076 \fB\-\-hmark\-dst\-prefix\fP \fIcidr\fP
2077 The destination address mask in CIDR notation.
2078 .TP
2079 \fB\-\-hmark\-sport\-mask\fP \fIvalue\fP
2080 A 16 bit source port mask in hexadecimal.
2081 .TP
2082 \fB\-\-hmark\-dport\-mask\fP \fIvalue\fP
2083 A 16 bit destination port mask in hexadecimal.
2084 .TP
2085 \fB\-\-hmark\-spi\-mask\fP \fIvalue\fP
2086 A 32 bit field with spi mask.
2087 .TP
2088 \fB\-\-hmark\-proto\-mask\fP \fIvalue\fP
2089 An 8 bit field with layer 4 protocol number.
2090 .TP
2091 \fB\-\-hmark\-rnd\fP \fIvalue\fP
2092 A 32 bit random custom value to feed hash calculation.
2093 .PP
2094 \fIExamples:\fP
2095 .PP
2096 iptables \-t mangle \-A PREROUTING \-m conntrack \-\-ctstate NEW
2097  \-j HMARK \-\-hmark-tuple ct,src,dst,proto \-\-hmark-offset 10000
2098 \-\-hmark\-mod 10 \-\-hmark\-rnd 0xfeedcafe
2099 .PP
2100 iptables \-t mangle \-A PREROUTING -j HMARK \-\-hmark\-offset 10000
2101 \-\-hmark-tuple src,dst,proto \-\-hmark-mod 10 \-\-hmark\-rnd 0xdeafbeef
2102 .SS IDLETIMER
2103 This target can be used to identify when interfaces have been idle for a
2104 certain period of time.  Timers are identified by labels and are created when
2105 a rule is set with a new label.  The rules also take a timeout value (in
2106 seconds) as an option.  If more than one rule uses the same timer label, the
2107 timer will be restarted whenever any of the rules get a hit.  One entry for
2108 each timer is created in sysfs.  This attribute contains the timer remaining
2109 for the timer to expire.  The attributes are located under the xt_idletimer
2110 class:
2111 .PP
2112 /sys/class/xt_idletimer/timers/<label>
2113 .PP
2114 When the timer expires, the target module sends a sysfs notification to the
2115 userspace, which can then decide what to do (eg. disconnect to save power).
2116 .TP
2117 \fB\-\-timeout\fP \fIamount\fP
2118 This is the time in seconds that will trigger the notification.
2119 .TP
2120 \fB\-\-label\fP \fIstring\fP
2121 This is a unique identifier for the timer.  The maximum length for the
2122 label string is 27 characters.
2123 .SS LED
2124 This creates an LED-trigger that can then be attached to system indicator
2125 lights, to blink or illuminate them when certain packets pass through the
2126 system. One example might be to light up an LED for a few minutes every time
2127 an SSH connection is made to the local machine. The following options control
2128 the trigger behavior:
2129 .TP
2130 \fB\-\-led\-trigger\-id\fP \fIname\fP
2131 This is the name given to the LED trigger. The actual name of the trigger
2132 will be prefixed with "netfilter-".
2133 .TP
2134 \fB\-\-led-delay\fP \fIms\fP
2135 This indicates how long (in milliseconds) the LED should be left illuminated
2136 when a packet arrives before being switched off again. The default is 0
2137 (blink as fast as possible.) The special value \fIinf\fP can be given to
2138 leave the LED on permanently once activated. (In this case the trigger will
2139 need to be manually detached and reattached to the LED device to switch it
2140 off again.)
2141 .TP
2142 \fB\-\-led\-always\-blink\fP
2143 Always make the LED blink on packet arrival, even if the LED is already on.
2144 This allows notification of new packets even with long delay values (which
2145 otherwise would result in a silent prolonging of the delay time.)
2146 .TP
2147 Example:
2148 .TP
2149 Create an LED trigger for incoming SSH traffic:
2150 iptables \-A INPUT \-p tcp \-\-dport 22 \-j LED \-\-led\-trigger\-id ssh
2151 .TP
2152 Then attach the new trigger to an LED:
2153 echo netfilter\-ssh >/sys/class/leds/\fIledname\fP/trigger
2154 .SS LOG
2155 Turn on kernel logging of matching packets.  When this option is set
2156 for a rule, the Linux kernel will print some information on all
2157 matching packets (like most IP/IPv6 header fields) via the kernel log
2158 (where it can be read with \fIdmesg(1)\fP or read in the syslog).
2159 .PP
2160 This is a "non-terminating target", i.e. rule traversal continues at
2161 the next rule.  So if you want to LOG the packets you refuse, use two
2162 separate rules with the same matching criteria, first using target LOG
2163 then DROP (or REJECT).
2164 .TP
2165 \fB\-\-log\-level\fP \fIlevel\fP
2166 Level of logging, which can be (system-specific) numeric or a mnemonic.
2167 Possible values are (in decreasing order of priority): \fBemerg\fP,
2168 \fBalert\fP, \fBcrit\fP, \fBerror\fP, \fBwarning\fP, \fBnotice\fP, \fBinfo\fP
2169 or \fBdebug\fP.
2170 .TP
2171 \fB\-\-log\-prefix\fP \fIprefix\fP
2172 Prefix log messages with the specified prefix; up to 29 letters long,
2173 and useful for distinguishing messages in the logs.
2174 .TP
2175 \fB\-\-log\-tcp\-sequence\fP
2176 Log TCP sequence numbers. This is a security risk if the log is
2177 readable by users.
2178 .TP
2179 \fB\-\-log\-tcp\-options\fP
2180 Log options from the TCP packet header.
2181 .TP
2182 \fB\-\-log\-ip\-options\fP
2183 Log options from the IP/IPv6 packet header.
2184 .TP
2185 \fB\-\-log\-uid\fP
2186 Log the userid of the process which generated the packet.
2187 .SS MARK
2188 This target is used to set the Netfilter mark value associated with the packet.
2189 It can, for example, be used in conjunction with routing based on fwmark (needs
2190 iproute2). If you plan on doing so, note that the mark needs to be set in the
2191 PREROUTING chain of the mangle table to affect routing.
2192 The mark field is 32 bits wide.
2193 .TP
2194 \fB\-\-set\-xmark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
2195 Zeroes out the bits given by \fImask\fP and XORs \fIvalue\fP into the packet
2196 mark ("nfmark"). If \fImask\fP is omitted, 0xFFFFFFFF is assumed.
2197 .TP
2198 \fB\-\-set\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
2199 Zeroes out the bits given by \fImask\fP and ORs \fIvalue\fP into the packet
2200 mark. If \fImask\fP is omitted, 0xFFFFFFFF is assumed.
2201 .PP
2202 The following mnemonics are available:
2203 .TP
2204 \fB\-\-and\-mark\fP \fIbits\fP
2205 Binary AND the nfmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark
2206 0/\fP\fIinvbits\fP, where \fIinvbits\fP is the binary negation of \fIbits\fP.)
2207 .TP
2208 \fB\-\-or\-mark\fP \fIbits\fP
2209 Binary OR the nfmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark\fP
2210 \fIbits\fP\fB/\fP\fIbits\fP.)
2211 .TP
2212 \fB\-\-xor\-mark\fP \fIbits\fP
2213 Binary XOR the nfmark with \fIbits\fP. (Mnemonic for \fB\-\-set\-xmark\fP
2214 \fIbits\fP\fB/0\fP.)
2215 .SS MASQUERADE
2216 This target is only valid in the
2217 .B nat
2218 table, in the
2219 .B POSTROUTING
2220 chain.  It should only be used with dynamically assigned IP (dialup)
2221 connections: if you have a static IP address, you should use the SNAT
2222 target.  Masquerading is equivalent to specifying a mapping to the IP
2223 address of the interface the packet is going out, but also has the
2224 effect that connections are
2225 .I forgotten
2226 when the interface goes down.  This is the correct behavior when the
2227 next dialup is unlikely to have the same interface address (and hence
2228 any established connections are lost anyway).
2229 .TP
2230 \fB\-\-to\-ports\fP \fIport\fP[\fB\-\fP\fIport\fP]
2231 This specifies a range of source ports to use, overriding the default
2232 .B SNAT
2233 source port-selection heuristics (see above).  This is only valid
2234 if the rule also specifies one of the following protocols:
2235 \fBtcp\fP, \fBudp\fP, \fBdccp\fP or \fBsctp\fP.
2236 .TP
2237 \fB\-\-random\fP
2238 Randomize source port mapping
2239 If option
2240 \fB\-\-random\fP
2241 is used then port mapping will be randomized (kernel >= 2.6.21).
2242 .TP
2243 IPv6 support available since Linux kernels >= 3.7.
2244 .SS MIRROR (IPv4-specific)
2245 This is an experimental demonstration target which inverts the source
2246 and destination fields in the IP header and retransmits the packet.
2247 It is only valid in the
2248 .BR INPUT ,
2249 .B FORWARD
2250 and
2251 .B PREROUTING
2252 chains, and user-defined chains which are only called from those
2253 chains.  Note that the outgoing packets are
2254 .B NOT
2255 seen by any packet filtering chains, connection tracking or NAT, to
2256 avoid loops and other problems.
2257 .SS NETMAP
2258 This target allows you to statically map a whole network of addresses onto
2259 another network of addresses.  It can only be used from rules in the
2260 .B nat
2261 table.
2262 .TP
2263 \fB\-\-to\fP \fIaddress\fP[\fB/\fP\fImask\fP]
2264 Network address to map to.  The resulting address will be constructed in the
2265 following way: All 'one' bits in the mask are filled in from the new `address'.
2266 All bits that are zero in the mask are filled in from the original address.
2267 .TP
2268 IPv6 support available since Linux kernels >= 3.7.
2269 .SS NFLOG
2270 This target provides logging of matching packets. When this target is
2271 set for a rule, the Linux kernel will pass the packet to the loaded
2272 logging backend to log the packet. This is usually used in combination
2273 with nfnetlink_log as logging backend, which will multicast the packet
2274 through a
2275 .IR netlink
2276 socket to the specified multicast group. One or more userspace processes
2277 may subscribe to the group to receive the packets. Like LOG, this is a
2278 non-terminating target, i.e. rule traversal continues at the next rule.
2279 .TP
2280 \fB\-\-nflog\-group\fP \fInlgroup\fP
2281 The netlink group (0 - 2^16\-1) to which packets are (only applicable for
2282 nfnetlink_log). The default value is 0.
2283 .TP
2284 \fB\-\-nflog\-prefix\fP \fIprefix\fP
2285 A prefix string to include in the log message, up to 64 characters
2286 long, useful for distinguishing messages in the logs.
2287 .TP
2288 \fB\-\-nflog\-range\fP \fIsize\fP
2289 The number of bytes to be copied to userspace (only applicable for
2290 nfnetlink_log). nfnetlink_log instances may specify their own
2291 range, this option overrides it.
2292 .TP
2293 \fB\-\-nflog\-threshold\fP \fIsize\fP
2294 Number of packets to queue inside the kernel before sending them
2295 to userspace (only applicable for nfnetlink_log). Higher values
2296 result in less overhead per packet, but increase delay until the
2297 packets reach userspace. The default value is 1.
2298 .BR
2299 .SS NFQUEUE
2300 This target passes the packet to userspace using the
2301 \fBnfnetlink_queue\fP handler.  The packet is put into the queue
2302 identified by its 16-bit queue number.  Userspace can inspect
2303 and modify the packet if desired. Userspace must then drop or
2304 reinject the packet into the kernel.  Please see libnetfilter_queue
2305 for details.
2306 .B
2307 nfnetlink_queue
2308 was added in Linux 2.6.14. The \fBqueue-balance\fP option was added in Linux 2.6.31,
2309 \fBqueue-bypass\fP in 2.6.39.
2310 .TP
2311 \fB\-\-queue\-num\fP \fIvalue\fP
2312 This specifies the QUEUE number to use. Valid queue numbers are 0 to 65535. The default value is 0.
2313 .PP
2314 .TP
2315 \fB\-\-queue\-balance\fP \fIvalue\fP\fB:\fP\fIvalue\fP
2316 This specifies a range of queues to use. Packets are then balanced across the given queues.
2317 This is useful for multicore systems: start multiple instances of the userspace program on
2318 queues x, x+1, .. x+n and use "\-\-queue\-balance \fIx\fP\fB:\fP\fIx+n\fP".
2319 Packets belonging to the same connection are put into the same nfqueue.
2320 .PP
2321 .TP
2322 \fB\-\-queue\-bypass\fP
2323 By default, if no userspace program is listening on an NFQUEUE, then all packets that are to be queued
2324 are dropped.  When this option is used, the NFQUEUE rule behaves like ACCEPT instead, and the packet
2325 will move on to the next table.
2326 .PP
2327 .TP
2328 \fB\-\-queue\-cpu-fanout\fP
2329 Available starting Linux kernel 3.10. When used together with
2330 \fB--queue-balance\fP this will use the CPU ID as an index to map packets to
2331 the queues. The idea is that you can improve performance if there's a queue
2332 per CPU. This requires \fB--queue-balance\fP to be specified.
2333 .SS NOTRACK
2334 This extension disables connection tracking for all packets matching that rule.
2335 It is equivalent with \-j CT \-\-notrack. Like CT, NOTRACK can only be used in
2336 the \fBraw\fP table.
2337 .SS RATEEST
2338 The RATEEST target collects statistics, performs rate estimation calculation
2339 and saves the results for later evaluation using the \fBrateest\fP match.
2340 .TP
2341 \fB\-\-rateest\-name\fP \fIname\fP
2342 Count matched packets into the pool referred to by \fIname\fP, which is freely
2343 choosable.
2344 .TP
2345 \fB\-\-rateest\-interval\fP \fIamount\fP{\fBs\fP|\fBms\fP|\fBus\fP}
2346 Rate measurement interval, in seconds, milliseconds or microseconds.
2347 .TP
2348 \fB\-\-rateest\-ewmalog\fP \fIvalue\fP
2349 Rate measurement averaging time constant.
2350 .SS REDIRECT
2351 This target is only valid in the
2352 .B nat
2353 table, in the
2354 .B PREROUTING
2355 and
2356 .B OUTPUT
2357 chains, and user-defined chains which are only called from those
2358 chains.  It redirects the packet to the machine itself by changing the
2359 destination IP to the primary address of the incoming interface
2360 (locally-generated packets are mapped to the localhost address,
2361 127.0.0.1 for IPv4 and ::1 for IPv6).
2362 .TP
2363 \fB\-\-to\-ports\fP \fIport\fP[\fB\-\fP\fIport\fP]
2364 This specifies a destination port or range of ports to use: without
2365 this, the destination port is never altered.  This is only valid
2366 if the rule also specifies one of the following protocols:
2367 \fBtcp\fP, \fBudp\fP, \fBdccp\fP or \fBsctp\fP.
2368 .TP
2369 \fB\-\-random\fP
2370 If option
2371 \fB\-\-random\fP
2372 is used then port mapping will be randomized (kernel >= 2.6.22).
2373 .TP
2374 IPv6 support available starting Linux kernels >= 3.7.
2375 .SS REJECT (IPv6-specific)
2376 This is used to send back an error packet in response to the matched
2377 packet: otherwise it is equivalent to 
2378 .B DROP
2379 so it is a terminating TARGET, ending rule traversal.
2380 This target is only valid in the
2381 .BR INPUT ,
2382 .B FORWARD
2383 and
2384 .B OUTPUT
2385 chains, and user-defined chains which are only called from those
2386 chains.  The following option controls the nature of the error packet
2387 returned:
2388 .TP
2389 \fB\-\-reject\-with\fP \fItype\fP
2390 The type given can be
2391 \fBicmp6\-no\-route\fP,
2392 \fBno\-route\fP,
2393 \fBicmp6\-adm\-prohibited\fP,
2394 \fBadm\-prohibited\fP,
2395 \fBicmp6\-addr\-unreachable\fP,
2396 \fBaddr\-unreach\fP, or
2397 \fBicmp6\-port\-unreachable\fP,
2398 which return the appropriate ICMPv6 error message (\fBicmp6\-port\-unreachable\fP is
2399 the default). Finally, the option
2400 \fBtcp\-reset\fP
2401 can be used on rules which only match the TCP protocol: this causes a
2402 TCP RST packet to be sent back.  This is mainly useful for blocking 
2403 .I ident
2404 (113/tcp) probes which frequently occur when sending mail to broken mail
2405 hosts (which won't accept your mail otherwise).
2406 \fBtcp\-reset\fP
2407 can only be used with kernel versions 2.6.14 or later.
2408 .SS REJECT (IPv4-specific)
2409 This is used to send back an error packet in response to the matched
2410 packet: otherwise it is equivalent to
2411 .B DROP
2412 so it is a terminating TARGET, ending rule traversal.
2413 This target is only valid in the
2414 .BR INPUT ,
2415 .B FORWARD
2416 and
2417 .B OUTPUT
2418 chains, and user-defined chains which are only called from those
2419 chains.  The following option controls the nature of the error packet
2420 returned:
2421 .TP
2422 \fB\-\-reject\-with\fP \fItype\fP
2423 The type given can be
2424 \fBicmp\-net\-unreachable\fP,
2425 \fBicmp\-host\-unreachable\fP,
2426 \fBicmp\-port\-unreachable\fP,
2427 \fBicmp\-proto\-unreachable\fP,
2428 \fBicmp\-net\-prohibited\fP,
2429 \fBicmp\-host\-prohibited\fP, or
2430 \fBicmp\-admin\-prohibited\fP (*),
2431 which return the appropriate ICMP error message (\fBicmp\-port\-unreachable\fP is
2432 the default).  The option
2433 \fBtcp\-reset\fP
2434 can be used on rules which only match the TCP protocol: this causes a
2435 TCP RST packet to be sent back.  This is mainly useful for blocking 
2436 .I ident
2437 (113/tcp) probes which frequently occur when sending mail to broken mail
2438 hosts (which won't accept your mail otherwise).
2439 .PP
2440 (*) Using icmp\-admin\-prohibited with kernels that do not support it will result in a plain DROP instead of REJECT
2441 .SS SAME (IPv4-specific)
2442 Similar to SNAT/DNAT depending on chain: it takes a range of addresses
2443 (`\-\-to 1.2.3.4\-1.2.3.7') and gives a client the same
2444 source-/destination-address for each connection.
2445 .PP
2446 N.B.: The DNAT target's \fB\-\-persistent\fP option replaced the SAME target.
2447 .TP
2448 \fB\-\-to\fP \fIipaddr\fP[\fB\-\fP\fIipaddr\fP]
2449 Addresses to map source to. May be specified more than once for
2450 multiple ranges.
2451 .TP
2452 \fB\-\-nodst\fP
2453 Don't use the destination-ip in the calculations when selecting the
2454 new source-ip
2455 .TP
2456 \fB\-\-random\fP
2457 Port mapping will be forcibly randomized to avoid attacks based on 
2458 port prediction (kernel >= 2.6.21).
2459 .SS SECMARK
2460 This is used to set the security mark value associated with the
2461 packet for use by security subsystems such as SELinux.  It is
2462 valid in the
2463 .B security
2464 table (for backwards compatibility with older kernels, it is also
2465 valid in the
2466 .B mangle
2467 table). The mark is 32 bits wide.
2468 .TP
2469 \fB\-\-selctx\fP \fIsecurity_context\fP
2470 .SS SET
2471 This module adds and/or deletes entries from IP sets which can be defined
2472 by ipset(8).
2473 .TP
2474 \fB\-\-add\-set\fP \fIsetname\fP \fIflag\fP[\fB,\fP\fIflag\fP...]
2475 add the address(es)/port(s) of the packet to the set
2476 .TP
2477 \fB\-\-del\-set\fP \fIsetname\fP \fIflag\fP[\fB,\fP\fIflag\fP...]
2478 delete the address(es)/port(s) of the packet from the set
2479 .IP
2480 where \fIflag\fP(s) are
2481 .BR "src"
2482 and/or
2483 .BR "dst"
2484 specifications and there can be no more than six of them.
2485 .TP
2486 \fB\-\-timeout\fP \fIvalue\fP
2487 when adding an entry, the timeout value to use instead of the default
2488 one from the set definition
2489 .TP
2490 \fB\-\-exist\fP
2491 when adding an entry if it already exists, reset the timeout value
2492 to the specified one or to the default from the set definition
2493 .PP
2494 Use of -j SET requires that ipset kernel support is provided, which, for
2495 standard kernels, is the case since Linux 2.6.39.
2496 .SS SNAT
2497 This target is only valid in the
2498 .B nat
2499 table, in the
2500 .B POSTROUTING
2501 and
2502 .B INPUT
2503 chains, and user-defined chains which are only called from those
2504 chains.  It specifies that the source address of the packet should be
2505 modified (and all future packets in this connection will also be
2506 mangled), and rules should cease being examined.  It takes the
2507 following options:
2508 .TP
2509 \fB\-\-to\-source\fP [\fIipaddr\fP[\fB\-\fP\fIipaddr\fP]][\fB:\fP\fIport\fP[\fB\-\fP\fIport\fP]]
2510 which can specify a single new source IP address, an inclusive range
2511 of IP addresses. Optionally a port range,
2512 if the rule also specifies one of the following protocols:
2513 \fBtcp\fP, \fBudp\fP, \fBdccp\fP or \fBsctp\fP.
2514 If no port range is specified, then source ports below 512 will be
2515 mapped to other ports below 512: those between 512 and 1023 inclusive
2516 will be mapped to ports below 1024, and other ports will be mapped to
2517 1024 or above. Where possible, no port alteration will occur.
2518 In Kernels up to 2.6.10, you can add several \-\-to\-source options. For those
2519 kernels, if you specify more than one source address, either via an address
2520 range or multiple \-\-to\-source options, a simple round-robin (one after another
2521 in cycle) takes place between these addresses.
2522 Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to multiple ranges
2523 anymore.
2524 .TP
2525 \fB\-\-random\fP
2526 If option
2527 \fB\-\-random\fP
2528 is used then port mapping will be randomized (kernel >= 2.6.21).
2529 .TP
2530 \fB\-\-persistent\fP
2531 Gives a client the same source-/destination-address for each connection.
2532 This supersedes the SAME target. Support for persistent mappings is available
2533 from 2.6.29-rc2.
2534 .PP
2535 Kernels prior to 2.6.36-rc1 don't have the ability to
2536 .B SNAT
2537 in the
2538 .B INPUT
2539 chain.
2540 .TP
2541 IPv6 support available since Linux kernels >= 3.7.
2542 .SS SNPT (IPv6-specific)
2543 Provides stateless source IPv6-to-IPv6 Network Prefix Translation (as described
2544 by RFC 6296).
2545 .PP
2546 You have to use this target in the
2547 .B mangle
2548 table, not in the
2549 .B nat
2550 table. It takes the following options:
2551 .TP
2552 \fB\-\-src\-pfx\fP [\fIprefix/\fP\fIlength]
2553 Set source prefix that you want to translate and length
2554 .TP
2555 \fB\-\-dst\-pfx\fP [\fIprefix/\fP\fIlength]
2556 Set destination prefix that you want to use in the translation and length
2557 .PP
2558 You have to use the DNPT target to undo the translation. Example:
2559 .IP
2560 ip6tables \-t mangle \-I POSTROUTING \-s fd00::/64 \! \-o vboxnet0
2561 \-j SNPT \-\-src-pfx fd00::/64 \-\-dst-pfx 2001:e20:2000:40f::/64
2562 .IP
2563 ip6tables \-t mangle \-I PREROUTING \-i wlan0 \-d 2001:e20:2000:40f::/64
2564 \-j DNPT \-\-src-pfx 2001:e20:2000:40f::/64 \-\-dst-pfx fd00::/64
2565 .PP
2566 You may need to enable IPv6 neighbor proxy:
2567 .IP
2568 sysctl -w net.ipv6.conf.all.proxy_ndp=1
2569 .PP
2570 You also have to use the
2571 .B NOTRACK
2572 target to disable connection tracking for translated flows.
2573 .SS TCPMSS
2574 This target allows to alter the MSS value of TCP SYN packets, to control
2575 the maximum size for that connection (usually limiting it to your
2576 outgoing interface's MTU minus 40 for IPv4 or 60 for IPv6, respectively).
2577 Of course, it can only be used
2578 in conjunction with
2579 \fB\-p tcp\fP.
2580 .PP
2581 This target is used to overcome criminally braindead ISPs or servers
2582 which block "ICMP Fragmentation Needed" or "ICMPv6 Packet Too Big"
2583 packets.  The symptoms of this
2584 problem are that everything works fine from your Linux
2585 firewall/router, but machines behind it can never exchange large
2586 packets:
2587 .IP 1. 4
2588 Web browsers connect, then hang with no data received.
2589 .IP 2. 4
2590 Small mail works fine, but large emails hang.
2591 .IP 3. 4
2592 ssh works fine, but scp hangs after initial handshaking.
2593 .PP
2594 Workaround: activate this option and add a rule to your firewall
2595 configuration like:
2596 .IP
2597  iptables \-t mangle \-A FORWARD \-p tcp \-\-tcp\-flags SYN,RST SYN
2598              \-j TCPMSS \-\-clamp\-mss\-to\-pmtu
2599 .TP
2600 \fB\-\-set\-mss\fP \fIvalue\fP
2601 Explicitly sets MSS option to specified value. If the MSS of the packet is
2602 already lower than \fIvalue\fP, it will \fBnot\fP be increased (from Linux
2603 2.6.25 onwards) to avoid more problems with hosts relying on a proper MSS.
2604 .TP
2605 \fB\-\-clamp\-mss\-to\-pmtu\fP
2606 Automatically clamp MSS value to (path_MTU \- 40 for IPv4; \-60 for IPv6).
2607 This may not function as desired where asymmetric routes with differing
2608 path MTU exist \(em the kernel uses the path MTU which it would use to send
2609 packets from itself to the source and destination IP addresses. Prior to
2610 Linux 2.6.25, only the path MTU to the destination IP address was
2611 considered by this option; subsequent kernels also consider the path MTU
2612 to the source IP address.
2613 .PP
2614 These options are mutually exclusive.
2615 .SS TCPOPTSTRIP
2616 This target will strip TCP options off a TCP packet. (It will actually replace
2617 them by NO-OPs.) As such, you will need to add the \fB\-p tcp\fP parameters.
2618 .TP
2619 \fB\-\-strip\-options\fP \fIoption\fP[\fB,\fP\fIoption\fP...]
2620 Strip the given option(s). The options may be specified by TCP option number or
2621 by symbolic name. The list of recognized options can be obtained by calling
2622 iptables with \fB\-j TCPOPTSTRIP \-h\fP.
2623 .SS TEE
2624 The \fBTEE\fP target will clone a packet and redirect this clone to another
2625 machine on the \fBlocal\fP network segment. In other words, the nexthop
2626 must be the target, or you will have to configure the nexthop to forward it
2627 further if so desired.
2628 .TP
2629 \fB\-\-gateway\fP \fIipaddr\fP
2630 Send the cloned packet to the host reachable at the given IP address.
2631 Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid.
2632 .PP
2633 To forward all incoming traffic on eth0 to an Network Layer logging box:
2634 .PP
2635 \-t mangle \-A PREROUTING \-i eth0 \-j TEE \-\-gateway 2001:db8::1
2636 .SS TOS
2637 This module sets the Type of Service field in the IPv4 header (including the
2638 "precedence" bits) or the Priority field in the IPv6 header. Note that TOS
2639 shares the same bits as DSCP and ECN. The TOS target is only valid in the
2640 \fBmangle\fP table.
2641 .TP
2642 \fB\-\-set\-tos\fP \fIvalue\fP[\fB/\fP\fImask\fP]
2643 Zeroes out the bits given by \fImask\fP (see NOTE below) and XORs \fIvalue\fP
2644 into the TOS/Priority field. If \fImask\fP is omitted, 0xFF is assumed.
2645 .TP
2646 \fB\-\-set\-tos\fP \fIsymbol\fP
2647 You can specify a symbolic name when using the TOS target for IPv4. It implies
2648 a mask of 0xFF (see NOTE below). The list of recognized TOS names can be
2649 obtained by calling iptables with \fB\-j TOS \-h\fP.
2650 .PP
2651 The following mnemonics are available:
2652 .TP
2653 \fB\-\-and\-tos\fP \fIbits\fP
2654 Binary AND the TOS value with \fIbits\fP. (Mnemonic for \fB\-\-set\-tos
2655 0/\fP\fIinvbits\fP, where \fIinvbits\fP is the binary negation of \fIbits\fP.
2656 See NOTE below.)
2657 .TP
2658 \fB\-\-or\-tos\fP \fIbits\fP
2659 Binary OR the TOS value with \fIbits\fP. (Mnemonic for \fB\-\-set\-tos\fP
2660 \fIbits\fP\fB/\fP\fIbits\fP. See NOTE below.)
2661 .TP
2662 \fB\-\-xor\-tos\fP \fIbits\fP
2663 Binary XOR the TOS value with \fIbits\fP. (Mnemonic for \fB\-\-set\-tos\fP
2664 \fIbits\fP\fB/0\fP. See NOTE below.)
2665 .PP
2666 NOTE: In Linux kernels up to and including 2.6.38, with the exception of
2667 longterm releases 2.6.32 (>=.42), 2.6.33 (>=.15), and 2.6.35 (>=.14), there is
2668 a bug whereby IPv6 TOS mangling does not behave as documented and differs from
2669 the IPv4 version. The TOS mask indicates the bits one wants to zero out, so it
2670 needs to be inverted before applying it to the original TOS field. However, the
2671 aformentioned kernels forgo the inversion which breaks --set-tos and its
2672 mnemonics.
2673 .SS TPROXY
2674 This target is only valid in the \fBmangle\fP table, in the \fBPREROUTING\fP
2675 chain and user-defined chains which are only called from this chain. It
2676 redirects the packet to a local socket without changing the packet header in
2677 any way. It can also change the mark value which can then be used in advanced
2678 routing rules.
2679 It takes three options:
2680 .TP
2681 \fB\-\-on\-port\fP \fIport\fP
2682 This specifies a destination port to use. It is a required option, 0 means the
2683 new destination port is the same as the original. This is only valid if the
2684 rule also specifies \fB\-p tcp\fP or \fB\-p udp\fP.
2685 .TP
2686 \fB\-\-on\-ip\fP \fIaddress\fP
2687 This specifies a destination address to use. By default the address is the IP
2688 address of the incoming interface. This is only valid if the rule also
2689 specifies \fB\-p tcp\fP or \fB\-p udp\fP.
2690 .TP
2691 \fB\-\-tproxy\-mark\fP \fIvalue\fP[\fB/\fP\fImask\fP]
2692 Marks packets with the given value/mask. The fwmark value set here can be used
2693 by advanced routing. (Required for transparent proxying to work: otherwise
2694 these packets will get forwarded, which is probably not what you want.)
2695 .SS TRACE
2696 This target marks packets so that the kernel will log every rule which match 
2697 the packets as those traverse the tables, chains, rules.
2698 .PP
2699 A logging backend, such as ip(6)t_LOG or nfnetlink_log, must be loaded for this
2700 to be visible.
2701 The packets are logged with the string prefix:
2702 "TRACE: tablename:chainname:type:rulenum " where type can be "rule" for 
2703 plain rule, "return" for implicit rule at the end of a user defined chain 
2704 and "policy" for the policy of the built in chains. 
2705 .br
2706 It can only be used in the
2707 .BR raw
2708 table.
2709 .SS TTL (IPv4-specific)
2710 This is used to modify the IPv4 TTL header field.  The TTL field determines
2711 how many hops (routers) a packet can traverse until it's time to live is
2712 exceeded.
2713 .PP
2714 Setting or incrementing the TTL field can potentially be very dangerous,
2715 so it should be avoided at any cost. This target is only valid in
2716 .B mangle
2717 table.
2718 .PP
2719 .B Don't ever set or increment the value on packets that leave your local network!
2720 .TP
2721 \fB\-\-ttl\-set\fP \fIvalue\fP
2722 Set the TTL value to `value'.
2723 .TP
2724 \fB\-\-ttl\-dec\fP \fIvalue\fP
2725 Decrement the TTL value `value' times.
2726 .TP
2727 \fB\-\-ttl\-inc\fP \fIvalue\fP
2728 Increment the TTL value `value' times.
2729 .SS ULOG (IPv4-specific)
2730 This is the deprecated ipv4-only predecessor of the NFLOG target.
2731 It provides userspace logging of matching packets.  When this
2732 target is set for a rule, the Linux kernel will multicast this packet
2733 through a
2734 .IR netlink 
2735 socket. One or more userspace processes may then subscribe to various 
2736 multicast groups and receive the packets.
2737 Like LOG, this is a "non-terminating target", i.e. rule traversal
2738 continues at the next rule.
2739 .TP
2740 \fB\-\-ulog\-nlgroup\fP \fInlgroup\fP
2741 This specifies the netlink group (1-32) to which the packet is sent.
2742 Default value is 1.
2743 .TP
2744 \fB\-\-ulog\-prefix\fP \fIprefix\fP
2745 Prefix log messages with the specified prefix; up to 32 characters
2746 long, and useful for distinguishing messages in the logs.
2747 .TP
2748 \fB\-\-ulog\-cprange\fP \fIsize\fP
2749 Number of bytes to be copied to userspace.  A value of 0 always copies
2750 the entire packet, regardless of its size.  Default is 0.
2751 .TP
2752 \fB\-\-ulog\-qthreshold\fP \fIsize\fP
2753 Number of packet to queue inside kernel.  Setting this value to, e.g. 10
2754 accumulates ten packets inside the kernel and transmits them as one
2755 netlink multipart message to userspace.  Default is 1 (for backwards
2756 compatibility).
2757 .br