Debian Codegraph @

upstream/mageia-cauldron/man8/iptables-extensions.8

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