1iptables-extensions(8)          iptables 1.8.7          iptables-extensions(8)
2
3
4

NAME

6       iptables-extensions  — list of extensions in the standard iptables dis‐
7       tribution
8

SYNOPSIS

10       ip6tables [-m name [module-options...]]   [-j  target-name  [target-op‐
11       tions...]
12
13       iptables  [-m  name  [module-options...]]   [-j target-name [target-op‐
14       tions...]
15

MATCH EXTENSIONS

17       iptables can use extended  packet  matching  modules  with  the  -m  or
18       --match  options,  followed  by  the matching module name; after these,
19       various extra command line options become available, depending  on  the
20       specific  module.   You  can specify multiple extended match modules in
21       one line, and you can use the -h or --help options after the module has
22       been  specified  to receive help specific to that module.  The extended
23       match modules are evaluated in the order  they  are  specified  in  the
24       rule.
25
26       If the -p or --protocol was specified and if and only if an unknown op‐
27       tion is encountered, iptables will try load a match module of the  same
28       name as the protocol, to try making the option available.
29
30   addrtype
31       This module matches packets based on their address type.  Address types
32       are used within the kernel networking stack  and  categorize  addresses
33       into various groups.  The exact definition of that group depends on the
34       specific layer three protocol.
35
36       The following address types are possible:
37
38       UNSPEC an unspecified address (i.e. 0.0.0.0)
39
40       UNICAST
41              an unicast address
42
43       LOCAL  a local address
44
45       BROADCAST
46              a broadcast address
47
48       ANYCAST
49              an anycast packet
50
51       MULTICAST
52              a multicast address
53
54       BLACKHOLE
55              a blackhole address
56
57       UNREACHABLE
58              an unreachable address
59
60       PROHIBIT
61              a prohibited address
62
63       THROW  FIXME
64
65       NAT    FIXME
66
67       XRESOLVE
68
69       [!] --src-type type
70              Matches if the source address is of given type
71
72       [!] --dst-type type
73              Matches if the destination address is of given type
74
75       --limit-iface-in
76              The address type checking can be limited to  the  interface  the
77              packet  is  coming in. This option is only valid in the PREROUT‐
78              ING, INPUT and FORWARD chains. It cannot be specified  with  the
79              --limit-iface-out option.
80
81       --limit-iface-out
82              The  address  type  checking can be limited to the interface the
83              packet is going out. This option is only valid in the  POSTROUT‐
84              ING,  OUTPUT and FORWARD chains. It cannot be specified with the
85              --limit-iface-in option.
86
87   ah (IPv6-specific)
88       This module matches the parameters in Authentication  header  of  IPsec
89       packets.
90
91       [!] --ahspi spi[:spi]
92              Matches SPI.
93
94       [!] --ahlen length
95              Total length of this header in octets.
96
97       --ahres
98              Matches if the reserved field is filled with zero.
99
100   ah (IPv4-specific)
101       This module matches the SPIs in Authentication header of IPsec packets.
102
103       [!] --ahspi spi[:spi]
104
105   bpf
106       Match  using Linux Socket Filter. Expects a path to an eBPF object or a
107       cBPF program in decimal format.
108
109       --object-pinned path
110              Pass a path to a pinned eBPF object.
111
112       Applications load eBPF programs into the kernel with the  bpf()  system
113       call and BPF_PROG_LOAD command and can pin them in a virtual filesystem
114       with BPF_OBJ_PIN.  To use a pinned object in iptables,  mount  the  bpf
115       filesystem using
116
117              mount -t bpf bpf ${BPF_MOUNT}
118
119       then insert the filter in iptables by path:
120
121              iptables      -A      OUTPUT      -m     bpf     --object-pinned
122              ${BPF_MOUNT}/{PINNED_PATH} -j ACCEPT
123
124       --bytecode code
125              Pass the BPF byte code format as generated by the  nfbpf_compile
126              utility.
127
128       The  code  format is similar to the output of the tcpdump -ddd command:
129       one line that stores the number of instructions, followed by  one  line
130       for  each  instruction. Instruction lines follow the pattern 'u16 u8 u8
131       u32' in decimal notation. Fields encode the operation, jump  offset  if
132       true, jump offset if false and generic multiuse field 'K'. Comments are
133       not supported.
134
135       For example, to read only packets matching 'ip  proto  6',  insert  the
136       following, without the comments or trailing whitespace:
137
138              4               # number of instructions
139              48 0 0 9        # load byte  ip->proto
140              21 0 1 6        # jump equal IPPROTO_TCP
141              6 0 0 1         # return     pass (non-zero)
142              6 0 0 0         # return     fail (zero)
143
144       You can pass this filter to the bpf match with the following command:
145
146              iptables  -A OUTPUT -m bpf --bytecode '4,48 0 0 9,21 0 1 6,6 0 0
147              1,6 0 0 0' -j ACCEPT
148
149       Or instead, you can invoke the nfbpf_compile utility.
150
151              iptables -A OUTPUT -m bpf  --bytecode  "`nfbpf_compile  RAW  'ip
152              proto 6'`" -j ACCEPT
153
154       Or use tcpdump -ddd. In that case, generate BPF targeting a device with
155       the same data link type as the xtables match. Iptables  passes  packets
156       from the network layer up, without mac layer. Select a device with data
157       link type RAW, such as a tun device:
158
159              ip tuntap add tun0 mode tun
160              ip link set tun0 up
161              tcpdump -ddd -i tun0 ip proto 6
162
163       See tcpdump -L -i $dev for a list of known data link types for a  given
164       device.
165
166       You may want to learn more about BPF from FreeBSD's bpf(4) manpage.
167
168   cgroup
169       [!] --path path
170              Match cgroup2 membership.
171
172              Each  socket  is  associated  with the v2 cgroup of the creating
173              process.  This matches packets coming from or going to all sock‐
174              ets in the sub-hierarchy of the specified path.  The path should
175              be relative to the root of the cgroup2 hierarchy.
176
177       [!] --cgroup classid
178              Match cgroup net_cls classid.
179
180              classid is the marker set through the cgroup net_cls controller.
181              This option and --path can't be used together.
182
183       Example:
184
185              iptables  -A  OUTPUT  -p  tcp --sport 80 -m cgroup ! --path ser‐
186              vice/http-server -j DROP
187
188              iptables -A OUTPUT -p tcp --sport 80 -m cgroup ! --cgroup  1  -j
189              DROP
190
191       IMPORTANT:  when  being  used in the INPUT chain, the cgroup matcher is
192       currently only of limited functionality, meaning it will only match  on
193       packets  that  are processed for local sockets through early socket de‐
194       muxing. Therefore, general usage on the INPUT chain is not advised  un‐
195       less the implications are well understood.
196
197       Available since Linux 3.14.
198
199   cluster
200       Allows you to deploy gateway and back-end load-sharing clusters without
201       the need of load-balancers.
202
203       This match requires that all the nodes see the same packets. Thus,  the
204       cluster  match  decides  if  this node has to handle a packet given the
205       following options:
206
207       --cluster-total-nodes num
208              Set number of total nodes in cluster.
209
210       [!] --cluster-local-node num
211              Set the local node number ID.
212
213       [!] --cluster-local-nodemask mask
214              Set the local node number ID mask. You can use this  option  in‐
215              stead of --cluster-local-node.
216
217       --cluster-hash-seed value
218              Set seed value of the Jenkins hash.
219
220       Example:
221
222              iptables  -A  PREROUTING  -t  mangle  -i eth1 -m cluster --clus‐
223              ter-total-nodes  2  --cluster-local-node  1  --cluster-hash-seed
224              0xdeadbeef -j MARK --set-mark 0xffff
225
226              iptables  -A  PREROUTING  -t  mangle  -i eth2 -m cluster --clus‐
227              ter-total-nodes  2  --cluster-local-node  1  --cluster-hash-seed
228              0xdeadbeef -j MARK --set-mark 0xffff
229
230              iptables -A PREROUTING -t mangle -i eth1 -m mark ! --mark 0xffff
231              -j DROP
232
233              iptables -A PREROUTING -t mangle -i eth2 -m mark ! --mark 0xffff
234              -j DROP
235
236       And the following commands to make all nodes see the same packets:
237
238              ip maddr add 01:00:5e:00:01:01 dev eth1
239
240              ip maddr add 01:00:5e:00:01:02 dev eth2
241
242              arptables -A OUTPUT -o eth1 --h-length 6 -j mangle --mangle-mac-
243              s 01:00:5e:00:01:01
244
245              arptables  -A  INPUT  -i  eth1  --h-length  6  --destination-mac
246              01:00:5e:00:01:01 -j mangle --mangle-mac-d 00:zz:yy:xx:5a:27
247
248              arptables  -A  OUTPUT  -o  eth2  --h-length  6  -j mangle --man‐
249              gle-mac-s 01:00:5e:00:01:02
250
251              arptables  -A  INPUT  -i  eth2  --h-length  6  --destination-mac
252              01:00:5e:00:01:02 -j mangle --mangle-mac-d 00:zz:yy:xx:5a:27
253
254       NOTE:  the  arptables  commands above use mainstream syntax. If you are
255       using arptables-jf included in some RedHat, CentOS and Fedora versions,
256       you  will  hit  syntax errors. Therefore, you'll have to adapt these to
257       the arptables-jf syntax to get them working.
258
259       In the case of TCP connections, pickup facility has to be  disabled  to
260       avoid marking TCP ACK packets coming in the reply direction as valid.
261
262              echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose
263
264   comment
265       Allows you to add comments (up to 256 characters) to any rule.
266
267       --comment comment
268
269       Example:
270              iptables -A INPUT -i eth1 -m comment --comment "my local LAN"
271
272   connbytes
273       Match  by  how  many  bytes  or packets a connection (or one of the two
274       flows constituting the connection) has transferred so far, or by  aver‐
275       age bytes per packet.
276
277       The counters are 64-bit and are thus not expected to overflow ;)
278
279       The  primary  use is to detect long-lived downloads and mark them to be
280       scheduled using a lower priority band in traffic control.
281
282       The transferred bytes per connection can also be viewed  through  `con‐
283       ntrack -L` and accessed via ctnetlink.
284
285       NOTE  that  for  connections  which have no accounting information, the
286       match will always return false.  The  "net.netfilter.nf_conntrack_acct"
287       sysctl  flag  controls  whether  new  connections  will  be byte/packet
288       counted. Existing connection flows will not be gaining/losing a/the ac‐
289       counting structure when be sysctl flag is flipped.
290
291       [!] --connbytes from[:to]
292              match  packets  from  a  connection  whose packets/bytes/average
293              packet size is more than FROM and less than TO bytes/packets. if
294              TO  is  omitted  only  FROM  check is done. "!" is used to match
295              packets not falling in the range.
296
297       --connbytes-dir {original|reply|both}
298              which packets to consider
299
300       --connbytes-mode {packets|bytes|avgpkt}
301              whether to check the amount of packets, number of  bytes  trans‐
302              ferred or the average size (in bytes) of all packets received so
303              far. Note that when "both" is used together with  "avgpkt",  and
304              data is going (mainly) only in one direction (for example HTTP),
305              the average packet size will be about half of  the  actual  data
306              packets.
307
308       Example:
309              iptables    ..    -m    connbytes    --connbytes    10000:100000
310              --connbytes-dir both --connbytes-mode bytes ...
311
312   connlabel
313       Module matches or adds connlabels to a connection.  connlabels are sim‐
314       ilar to connmarks, except labels are bit-based; i.e.  all labels may be
315       attached to a flow at the same time.  Up to 128 unique labels are  cur‐
316       rently supported.
317
318       [!] --label name
319              matches  if label name has been set on a connection.  Instead of
320              a name (which will be translated to a number,  see  EXAMPLE  be‐
321              low), a number may be used instead.  Using a number always over‐
322              rides connlabel.conf.
323
324       --set  if the label has not been set on the connection, set  it.   Note
325              that setting a label can fail.  This is because the kernel allo‐
326              cates the conntrack label storage area when  the  connection  is
327              created,  and  it only reserves the amount of memory required by
328              the ruleset that exists at the time the connection  is  created.
329              In  this  case, the match will fail (or succeed, in case --label
330              option was negated).
331
332       This match depends on libnetfilter_conntrack  1.0.4  or  later.   Label
333       translation  is  done via the /etc/xtables/connlabel.conf configuration
334       file.
335
336       Example:
337
338              0    eth0-in
339              1    eth0-out
340              2    ppp-in
341              3    ppp-out
342              4    bulk-traffic
343              5    interactive
344
345   connlimit
346       Allows you to restrict the number of parallel connections to  a  server
347       per client IP address (or client address block).
348
349       --connlimit-upto n
350              Match if the number of existing connections is below or equal n.
351
352       --connlimit-above n
353              Match if the number of existing connections is above n.
354
355       --connlimit-mask prefix_length
356              Group  hosts  using  the prefix length. For IPv4, this must be a
357              number between (including) 0 and 32. For  IPv6,  between  0  and
358              128.  If not specified, the maximum prefix length for the appli‐
359              cable protocol is used.
360
361       --connlimit-saddr
362              Apply the limit onto the source group. This is  the  default  if
363              --connlimit-daddr is not specified.
364
365       --connlimit-daddr
366              Apply the limit onto the destination group.
367
368       Examples:
369
370       # allow 2 telnet connections per client host
371              iptables   -A  INPUT  -p  tcp  --syn  --dport  23  -m  connlimit
372              --connlimit-above 2 -j REJECT
373
374       # you can also match the other way around:
375              iptables  -A  INPUT  -p  tcp  --syn  --dport  23  -m   connlimit
376              --connlimit-upto 2 -j ACCEPT
377
378       #  limit  the  number of parallel HTTP requests to 16 per class C sized
379       source network (24 bit netmask)
380              iptables -p tcp --syn --dport 80 -m connlimit  --connlimit-above
381              16 --connlimit-mask 24 -j REJECT
382
383       #  limit  the number of parallel HTTP requests to 16 for the link local
384       network
385              (ipv6) ip6tables  -p  tcp  --syn  --dport  80  -s  fe80::/64  -m
386              connlimit --connlimit-above 16 --connlimit-mask 64 -j REJECT
387
388       # Limit the number of connections to a particular host:
389              ip6tables  -p  tcp  --syn  --dport 49152:65535 -d 2001:db8::1 -m
390              connlimit --connlimit-above 100 -j REJECT
391
392   connmark
393       This module matches the netfilter mark field associated with a  connec‐
394       tion (which can be set using the CONNMARK target below).
395
396       [!] --mark value[/mask]
397              Matches  packets  in connections with the given mark value (if a
398              mask is specified, this is logically ANDed with the mark  before
399              the comparison).
400
401   conntrack
402       This  module,  when combined with connection tracking, allows access to
403       the connection tracking state for this packet/connection.
404
405       [!] --ctstate statelist
406              statelist is a comma separated list of the connection states  to
407              match.  Possible states are listed below.
408
409       [!] --ctproto l4proto
410              Layer-4 protocol to match (by number or name)
411
412       [!] --ctorigsrc address[/mask]
413
414       [!] --ctorigdst address[/mask]
415
416       [!] --ctreplsrc address[/mask]
417
418       [!] --ctrepldst address[/mask]
419              Match against original/reply source/destination address
420
421       [!] --ctorigsrcport port[:port]
422
423       [!] --ctorigdstport port[:port]
424
425       [!] --ctreplsrcport port[:port]
426
427       [!] --ctrepldstport port[:port]
428              Match    against    original/reply    source/destination    port
429              (TCP/UDP/etc.) or GRE key.  Matching against port ranges is only
430              supported in kernel versions above 2.6.38.
431
432       [!] --ctstatus statelist
433              statuslist  is a comma separated list of the connection statuses
434              to match.  Possible statuses are listed below.
435
436       [!] --ctexpire time[:time]
437              Match remaining lifetime in seconds against given value or range
438              of values (inclusive)
439
440       --ctdir {ORIGINAL|REPLY}
441              Match  packets  that  are flowing in the specified direction. If
442              this flag is not specified at all, matches packets in  both  di‐
443              rections.
444
445       States for --ctstate:
446
447       INVALID
448              The packet is associated with no known connection.
449
450       NEW    The  packet has started a new connection or otherwise associated
451              with a connection which has not seen packets in both directions.
452
453       ESTABLISHED
454              The packet is associated with a connection which has seen  pack‐
455              ets in both directions.
456
457       RELATED
458              The  packet is starting a new connection, but is associated with
459              an existing connection, such as an FTP data transfer or an  ICMP
460              error.
461
462       UNTRACKED
463              The  packet  is not tracked at all, which happens if you explic‐
464              itly untrack it by using -j CT --notrack in the raw table.
465
466       SNAT   A virtual state, matching if the original source address differs
467              from the reply destination.
468
469       DNAT   A  virtual  state,  matching if the original destination differs
470              from the reply source.
471
472       Statuses for --ctstatus:
473
474       NONE   None of the below.
475
476       EXPECTED
477              This is an expected connection (i.e. a conntrack helper  set  it
478              up).
479
480       SEEN_REPLY
481              Conntrack has seen packets in both directions.
482
483       ASSURED
484              Conntrack entry should never be early-expired.
485
486       CONFIRMED
487              Connection is confirmed: originating packet has left box.
488
489   cpu
490       [!] --cpu number
491              Match  cpu  handling  this  packet.  cpus are numbered from 0 to
492              NR_CPUS-1 Can be used in combination  with  RPS  (Remote  Packet
493              Steering)  or  multiqueue NICs to spread network traffic on dif‐
494              ferent queues.
495
496       Example:
497
498       iptables -t nat -A PREROUTING -p tcp --dport 80 -m cpu --cpu 0 -j REDI‐
499       RECT --to-port 8080
500
501       iptables -t nat -A PREROUTING -p tcp --dport 80 -m cpu --cpu 1 -j REDI‐
502       RECT --to-port 8081
503
504       Available since Linux 2.6.36.
505
506   dccp
507       [!] --source-port,--sport port[:port]
508
509       [!] --destination-port,--dport port[:port]
510
511       [!] --dccp-types mask
512              Match when the DCCP packet type is one of 'mask'.  'mask'  is  a
513              comma-separated list of packet types.  Packet types are: REQUEST
514              RESPONSE DATA ACK DATAACK CLOSEREQ CLOSE RESET SYNC SYNCACK  IN‐
515              VALID.
516
517       [!] --dccp-option number
518              Match if DCCP option set.
519
520   devgroup
521       Match device group of a packets incoming/outgoing interface.
522
523       [!] --src-group name
524              Match device group of incoming device
525
526       [!] --dst-group name
527              Match device group of outgoing device
528
529   dscp
530       This module matches the 6 bit DSCP field within the TOS field in the IP
531       header.  DSCP has superseded TOS within the IETF.
532
533       [!] --dscp value
534              Match against a numeric (decimal or hex) value [0-63].
535
536       [!] --dscp-class class
537              Match the DiffServ class. This value may be any of the  BE,  EF,
538              AFxx or CSx classes.  It will then be converted into its accord‐
539              ing numeric value.
540
541   dst (IPv6-specific)
542       This module matches the parameters in Destination Options header
543
544       [!] --dst-len length
545              Total length of this header in octets.
546
547       --dst-opts type[:length][,type[:length]...]
548              numeric type of option and the length  of  the  option  data  in
549              octets.
550
551   ecn
552       This  allows you to match the ECN bits of the IPv4/IPv6 and TCP header.
553       ECN is the Explicit Congestion Notification mechanism as  specified  in
554       RFC3168
555
556       [!] --ecn-tcp-cwr
557              This matches if the TCP ECN CWR (Congestion Window Received) bit
558              is set.
559
560       [!] --ecn-tcp-ece
561              This matches if the TCP ECN ECE (ECN Echo) bit is set.
562
563       [!] --ecn-ip-ect num
564              This matches a particular IPv4/IPv6 ECT (ECN-Capable Transport).
565              You have to specify a number between `0' and `3'.
566
567   esp
568       This module matches the SPIs in ESP header of IPsec packets.
569
570       [!] --espspi spi[:spi]
571
572   eui64 (IPv6-specific)
573       This  module matches the EUI-64 part of a stateless autoconfigured IPv6
574       address.  It compares the EUI-64 derived from the source MAC address in
575       Ethernet  frame  with the lower 64 bits of the IPv6 source address. But
576       "Universal/Local" bit is not compared. This module doesn't match  other
577       link  layer  frame, and is only valid in the PREROUTING, INPUT and FOR‐
578       WARD chains.
579
580   frag (IPv6-specific)
581       This module matches the parameters in Fragment header.
582
583       [!] --fragid id[:id]
584              Matches the given Identification or range of it.
585
586       [!] --fraglen length
587              This option cannot be used with kernel version 2.6.10 or  later.
588              The  length of Fragment header is static and this option doesn't
589              make sense.
590
591       --fragres
592              Matches if the reserved fields are filled with zero.
593
594       --fragfirst
595              Matches on the first fragment.
596
597       --fragmore
598              Matches if there are more fragments.
599
600       --fraglast
601              Matches if this is the last fragment.
602
603   hashlimit
604       hashlimit uses hash buckets to express a rate limiting match (like  the
605       limit  match)  for a group of connections using a single iptables rule.
606       Grouping can be done per-hostgroup (source and/or destination  address)
607       and/or  per-port.  It  gives  you the ability to express "N packets per
608       time quantum per group" or "N bytes per seconds" (see  below  for  some
609       examples).
610
611       A  hash  limit option (--hashlimit-upto, --hashlimit-above) and --hash‐
612       limit-name are required.
613
614       --hashlimit-upto amount[/second|/minute|/hour|/day]
615              Match if the rate is below or equal  to  amount/quantum.  It  is
616              specified either as a number, with an optional time quantum suf‐
617              fix (the default is 3/hour), or  as  amountb/second  (number  of
618              bytes per second).
619
620       --hashlimit-above amount[/second|/minute|/hour|/day]
621              Match if the rate is above amount/quantum.
622
623       --hashlimit-burst amount
624              Maximum  initial  number  of  packets to match: this number gets
625              recharged by one every time the limit  specified  above  is  not
626              reached,  up  to this number; the default is 5.  When byte-based
627              rate matching is requested, this option specifies the amount  of
628              bytes  that  can  exceed  the given rate.  This option should be
629              used with caution -- if the entry expires, the  burst  value  is
630              reset too.
631
632       --hashlimit-mode {srcip|srcport|dstip|dstport},...
633              A comma-separated list of objects to take into consideration. If
634              no --hashlimit-mode option is given, hashlimit acts like  limit,
635              but at the expensive of doing the hash housekeeping.
636
637       --hashlimit-srcmask prefix
638              When  --hashlimit-mode  srcip  is used, all source addresses en‐
639              countered will be grouped according to the given  prefix  length
640              and  the  so-created subnet will be subject to hashlimit. prefix
641              must be between (inclusive) 0 and 32. Note that --hashlimit-src‐
642              mask 0 is basically doing the same thing as not specifying srcip
643              for --hashlimit-mode, but is technically more expensive.
644
645       --hashlimit-dstmask prefix
646              Like --hashlimit-srcmask, but for destination addresses.
647
648       --hashlimit-name foo
649              The name for the /proc/net/ipt_hashlimit/foo entry.
650
651       --hashlimit-htable-size buckets
652              The number of buckets of the hash table
653
654       --hashlimit-htable-max entries
655              Maximum entries in the hash.
656
657       --hashlimit-htable-expire msec
658              After how many milliseconds do hash entries expire.
659
660       --hashlimit-htable-gcinterval msec
661              How many milliseconds between garbage collection intervals.
662
663       --hashlimit-rate-match
664              Classify the flow instead of rate-limiting it. This acts like  a
665              true/false  match  on  whether the rate is above/below a certain
666              number
667
668       --hashlimit-rate-interval sec
669              Can be used with --hashlimit-rate-match to specify the  interval
670              at which the rate should be sampled
671
672       Examples:
673
674       matching on source host
675              "1000 packets per second for every host in 192.168.0.0/16" => -s
676              192.168.0.0/16 --hashlimit-mode srcip --hashlimit-upto 1000/sec
677
678       matching on source port
679              "100 packets per second for every service of 192.168.1.1" =>  -s
680              192.168.1.1 --hashlimit-mode srcport --hashlimit-upto 100/sec
681
682       matching on subnet
683              "10000  packets per minute for every /28 subnet (groups of 8 ad‐
684              dresses) in 10.0.0.0/8" =>  -s  10.0.0.0/8  --hashlimit-mask  28
685              --hashlimit-upto 10000/min
686
687       matching bytes per second
688              "flows exceeding 512kbyte/s" => --hashlimit-mode srcip,dstip,sr‐
689              cport,dstport --hashlimit-above 512kb/s
690
691       matching bytes per second
692              "hosts that exceed 512kbyte/s, but permit up to 1Megabytes with‐
693              out  matching"  --hashlimit-mode dstip --hashlimit-above 512kb/s
694              --hashlimit-burst 1mb
695
696   hbh (IPv6-specific)
697       This module matches the parameters in Hop-by-Hop Options header
698
699       [!] --hbh-len length
700              Total length of this header in octets.
701
702       --hbh-opts type[:length][,type[:length]...]
703              numeric type of option and the length  of  the  option  data  in
704              octets.
705
706   helper
707       This module matches packets related to a specific conntrack-helper.
708
709       [!] --helper string
710              Matches packets related to the specified conntrack-helper.
711
712              string  can be "ftp" for packets related to a ftp-session on de‐
713              fault port.  For other ports append -portnr to  the  value,  ie.
714              "ftp-2121".
715
716              Same rules apply for other conntrack-helpers.
717
718   hl (IPv6-specific)
719       This module matches the Hop Limit field in the IPv6 header.
720
721       [!] --hl-eq value
722              Matches if Hop Limit equals value.
723
724       --hl-lt value
725              Matches if Hop Limit is less than value.
726
727       --hl-gt value
728              Matches if Hop Limit is greater than value.
729
730   icmp (IPv4-specific)
731       This  extension  can be used if `--protocol icmp' is specified. It pro‐
732       vides the following option:
733
734       [!] --icmp-type {type[/code]|typename}
735              This allows specification of the ICMP type, which can be  a  nu‐
736              meric  ICMP  type, type/code pair, or one of the ICMP type names
737              shown by the command
738               iptables -p icmp -h
739
740   icmp6 (IPv6-specific)
741       This extension can be used if  `--protocol  ipv6-icmp'  or  `--protocol
742       icmpv6' is specified. It provides the following option:
743
744       [!] --icmpv6-type type[/code]|typename
745              This allows specification of the ICMPv6 type, which can be a nu‐
746              meric ICMPv6 type, type and code, or  one  of  the  ICMPv6  type
747              names shown by the command
748               ip6tables -p ipv6-icmp -h
749
750   iprange
751       This matches on a given arbitrary range of IP addresses.
752
753       [!] --src-range from[-to]
754              Match source IP in the specified range.
755
756       [!] --dst-range from[-to]
757              Match destination IP in the specified range.
758
759   ipv6header (IPv6-specific)
760       This module matches IPv6 extension headers and/or upper layer header.
761
762       --soft Matches if the packet includes any of the headers specified with
763              --header.
764
765       [!] --header header[,header...]
766              Matches the packet which EXACTLY includes all specified headers.
767              The headers encapsulated with ESP header are out of scope.  Pos‐
768              sible header types can be:
769
770       hop|hop-by-hop
771              Hop-by-Hop Options header
772
773       dst    Destination Options header
774
775       route  Routing header
776
777       frag   Fragment header
778
779       auth   Authentication header
780
781       esp    Encapsulating Security Payload header
782
783       none   No Next header which matches 59 in the 'Next  Header  field'  of
784              IPv6 header or any IPv6 extension headers
785
786       prot   which  matches  any upper layer protocol header. A protocol name
787              from /etc/protocols and numeric value also allowed.  The  number
788              255 is equivalent to prot.
789
790   ipvs
791       Match IPVS connection properties.
792
793       [!] --ipvs
794              packet belongs to an IPVS connection
795
796       Any of the following options implies --ipvs (even negated)
797
798       [!] --vproto protocol
799              VIP protocol to match; by number or name, e.g. "tcp"
800
801       [!] --vaddr address[/mask]
802              VIP address to match
803
804       [!] --vport port
805              VIP port to match; by number or name, e.g. "http"
806
807       --vdir {ORIGINAL|REPLY}
808              flow direction of packet
809
810       [!] --vmethod {GATE|IPIP|MASQ}
811              IPVS forwarding method used
812
813       [!] --vportctl port
814              VIP port of the controlling connection to match, e.g. 21 for FTP
815
816   length
817       This  module  matches  the  length of the layer-3 payload (e.g. layer-4
818       packet) of a packet against a specific value or range of values.
819
820       [!] --length length[:length]
821
822   limit
823       This module matches at a limited rate using a token bucket  filter.   A
824       rule  using  this extension will match until this limit is reached.  It
825       can be used in combination with the LOG target to give limited logging,
826       for example.
827
828       xt_limit  has no negation support - you will have to use -m hashlimit !
829       --hashlimit rate in this case whilst omitting --hashlimit-mode.
830
831       --limit rate[/second|/minute|/hour|/day]
832              Maximum average matching rate: specified as a  number,  with  an
833              optional  `/second',  `/minute',  `/hour', or `/day' suffix; the
834              default is 3/hour.
835
836       --limit-burst number
837              Maximum initial number of packets to  match:  this  number  gets
838              recharged  by  one  every  time the limit specified above is not
839              reached, up to this number; the default is 5.
840
841   mac
842       [!] --mac-source address
843              Match  source  MAC  address.    It   must   be   of   the   form
844              XX:XX:XX:XX:XX:XX.   Note that this only makes sense for packets
845              coming from an Ethernet device and entering the PREROUTING, FOR‐
846              WARD or INPUT chains.
847
848   mark
849       This  module  matches the netfilter mark field associated with a packet
850       (which can be set using the MARK target below).
851
852       [!] --mark value[/mask]
853              Matches packets with the given unsigned mark value (if a mask is
854              specified, this is logically ANDed with the mask before the com‐
855              parison).
856
857   mh (IPv6-specific)
858       This extension is loaded if `--protocol ipv6-mh' or `--protocol mh'  is
859       specified. It provides the following option:
860
861       [!] --mh-type type[:type]
862              This allows specification of the Mobility Header(MH) type, which
863              can be a numeric MH type, type or one of the MH type names shown
864              by the command
865               ip6tables -p mh -h
866
867   multiport
868       This  module  matches  a  set of source or destination ports.  Up to 15
869       ports can be specified.  A port range (port:port) counts as two  ports.
870       It can only be used in conjunction with one of the following protocols:
871       tcp, udp, udplite, dccp and sctp.
872
873       [!] --source-ports,--sports port[,port|,port:port]...
874              Match if the source port is one of the given  ports.   The  flag
875              --sports  is  a convenient alias for this option. Multiple ports
876              or port ranges are separated using a comma, and a port range  is
877              specified  using  a  colon.  53,1024:65535 would therefore match
878              ports 53 and all from 1024 through 65535.
879
880       [!] --destination-ports,--dports port[,port|,port:port]...
881              Match if the destination port is one of the  given  ports.   The
882              flag --dports is a convenient alias for this option.
883
884       [!] --ports port[,port|,port:port]...
885              Match if either the source or destination ports are equal to one
886              of the given ports.
887
888   nfacct
889       The nfacct match provides the extended  accounting  infrastructure  for
890       iptables.   You  have  to  use  this match together with the standalone
891       user-space utility nfacct(8)
892
893       The only option available for this match is the following:
894
895       --nfacct-name name
896              This allows you to specify the existing object name that will be
897              use for accounting the traffic that this rule-set is matching.
898
899       To use this extension, you have to create an accounting object:
900
901              nfacct add http-traffic
902
903       Then, you have to attach it to the accounting object via iptables:
904
905              iptables  -I  INPUT  -p  tcp  --sport 80 -m nfacct --nfacct-name
906              http-traffic
907
908              iptables -I OUTPUT -p tcp --dport  80  -m  nfacct  --nfacct-name
909              http-traffic
910
911       Then, you can check for the amount of traffic that the rules match:
912
913              nfacct get http-traffic
914
915              {  pkts = 00000000000000000156, bytes = 00000000000000151786 } =
916              http-traffic;
917
918       You can obtain nfacct(8)  from  http://www.netfilter.org  or,  alterna‐
919       tively, from the git.netfilter.org repository.
920
921   osf
922       The  osf module does passive operating system fingerprinting. This mod‐
923       ule compares some data (Window Size, MSS, options and their order, TTL,
924       DF, and others) from packets with the SYN bit set.
925
926       [!] --genre string
927              Match  an operating system genre by using a passive fingerprint‐
928              ing.
929
930       --ttl level
931              Do additional TTL checks on the packet to determine the  operat‐
932              ing system.  level can be one of the following values:
933
934       •   0  - True IP address and fingerprint TTL comparison. This generally
935           works for LANs.
936
937       •   1 - Check if the IP header's TTL is less than the fingerprint  one.
938           Works for globally-routable addresses.
939
940       •   2 - Do not compare the TTL at all.
941
942       --log level
943           Log  determined genres into dmesg even if they do not match the de‐
944           sired one.  level can be one of the following values:
945
946       •   0 - Log all matched or unknown signatures
947
948       •   1 - Log only the first one
949
950       •   2 - Log all known matched signatures
951
952       You may find something like this in syslog:
953
954       Windows [2000:SP3:Windows XP Pro SP1, 2000  SP3]:  11.22.33.55:4024  ->
955       11.22.33.44:139  hops=3  Linux [2.5-2.6:] : 1.2.3.4:42624 -> 1.2.3.5:22
956       hops=4
957
958       OS fingerprints are loadable using the nfnl_osf program. To  load  fin‐
959       gerprints from a file, use:
960
961       nfnl_osf -f /usr/share/xtables/pf.os
962
963       To remove them again,
964
965       nfnl_osf -f /usr/share/xtables/pf.os -d
966
967       The  fingerprint  database  can  be  downloaded  from  http://www.open
968       bsd.org/cgi-bin/cvsweb/src/etc/pf.os .
969
970   owner
971       This module attempts to match various  characteristics  of  the  packet
972       creator, for locally generated packets. This match is only valid in the
973       OUTPUT and POSTROUTING chains. Forwarded packets do not have any socket
974       associated with them. Packets from kernel threads do have a socket, but
975       usually no owner.
976
977       [!] --uid-owner username
978
979       [!] --uid-owner userid[-userid]
980              Matches if the packet socket's file structure (if it has one) is
981              owned  by  the given user. You may also specify a numerical UID,
982              or an UID range.
983
984       [!] --gid-owner groupname
985
986       [!] --gid-owner groupid[-groupid]
987              Matches if the packet socket's file structure is  owned  by  the
988              given  group.   You  may  also specify a numerical GID, or a GID
989              range.
990
991       --suppl-groups
992              Causes group(s) specified with --gid-owner to be also checked in
993              the supplementary groups of a process.
994
995       [!] --socket-exists
996              Matches if the packet is associated with a socket.
997
998   physdev
999       This  module  matches  on  the bridge port input and output devices en‐
1000       slaved to a bridge device. This module is a part of the  infrastructure
1001       that  enables a transparent bridging IP firewall and is only useful for
1002       kernel versions above version 2.5.44.
1003
1004       [!] --physdev-in name
1005              Name of a bridge port via which a packet is received  (only  for
1006              packets  entering  the INPUT, FORWARD and PREROUTING chains). If
1007              the interface name ends in a "+", then any interface  which  be‐
1008              gins  with  this  name  will  match. If the packet didn't arrive
1009              through a bridge device, this packet won't  match  this  option,
1010              unless '!' is used.
1011
1012       [!] --physdev-out name
1013              Name  of  a  bridge  port via which a packet is going to be sent
1014              (for  bridged  packets  entering  the  FORWARD  and  POSTROUTING
1015              chains).   If  the interface name ends in a "+", then any inter‐
1016              face which begins with this name will match.
1017
1018       [!] --physdev-is-in
1019              Matches if the packet has entered through a bridge interface.
1020
1021       [!] --physdev-is-out
1022              Matches if the packet will leave through a bridge interface.
1023
1024       [!] --physdev-is-bridged
1025              Matches if the packet is being bridged and therefore is not  be‐
1026              ing  routed.  This is only useful in the FORWARD and POSTROUTING
1027              chains.
1028
1029   pkttype
1030       This module matches the link-layer packet type.
1031
1032       [!] --pkt-type {unicast|broadcast|multicast}
1033
1034   policy
1035       This module matches the policy used by IPsec for handling a packet.
1036
1037       --dir {in|out}
1038              Used to select whether to match the policy used  for  decapsula‐
1039              tion  or  the policy that will be used for encapsulation.  in is
1040              valid in the PREROUTING, INPUT and FORWARD chains, out is  valid
1041              in the POSTROUTING, OUTPUT and FORWARD chains.
1042
1043       --pol {none|ipsec}
1044              Matches if the packet is subject to IPsec processing. --pol none
1045              cannot be combined with --strict.
1046
1047       --strict
1048              Selects whether to match the exact policy or match if  any  rule
1049              of the policy matches the given policy.
1050
1051       For  each  policy  element  that is to be described, one can use one or
1052       more of the following options. When --strict is in effect, at least one
1053       must be used per element.
1054
1055       [!] --reqid id
1056              Matches the reqid of the policy rule. The reqid can be specified
1057              with setkey(8) using unique:id as level.
1058
1059       [!] --spi spi
1060              Matches the SPI of the SA.
1061
1062       [!] --proto {ah|esp|ipcomp}
1063              Matches the encapsulation protocol.
1064
1065       [!] --mode {tunnel|transport}
1066              Matches the encapsulation mode.
1067
1068       [!] --tunnel-src addr[/mask]
1069              Matches the source end-point address of a tunnel mode SA.   Only
1070              valid with --mode tunnel.
1071
1072       [!] --tunnel-dst addr[/mask]
1073              Matches  the  destination end-point address of a tunnel mode SA.
1074              Only valid with --mode tunnel.
1075
1076       --next Start the next element in the policy specification. Can only  be
1077              used with --strict.
1078
1079   quota
1080       Implements  network  quotas  by  decrementing  a byte counter with each
1081       packet. The condition matches until the byte counter reaches zero.  Be‐
1082       havior is reversed with negation (i.e. the condition does not match un‐
1083       til the byte counter reaches zero).
1084
1085       [!] --quota bytes
1086              The quota in bytes.
1087
1088   rateest
1089       The rate estimator can match on estimated rates as collected by the RA‐
1090       TEEST  target. It supports matching on absolute bps/pps values, compar‐
1091       ing two rate estimators and matching on the difference between two rate
1092       estimators.
1093
1094       For a better understanding of the available options, these are all pos‐
1095       sible combinations:
1096
1097rateest operator rateest-bps
1098
1099rateest operator rateest-pps
1100
1101       •   (rateest minus rateest-bps1) operator rateest-bps2
1102
1103       •   (rateest minus rateest-pps1) operator rateest-pps2
1104
1105rateest1 operator rateest2 rateest-bps(without rate!)
1106
1107rateest1 operator rateest2 rateest-pps(without rate!)
1108
1109       •   (rateest1 minus rateest-bps1)  operator  (rateest2  minus  rateest-
1110           bps2)
1111
1112       •   (rateest1  minus  rateest-pps1)  operator  (rateest2 minus rateest-
1113           pps2)
1114
1115       --rateest-delta
1116           For each estimator (either absolute or  relative  mode),  calculate
1117           the  difference  between the estimator-determined flow rate and the
1118           static value chosen with the BPS/PPS options. If the flow  rate  is
1119           higher than the specified BPS/PPS, 0 will be used instead of a neg‐
1120           ative value. In other words, "max(0, rateest#_rate - rateest#_bps)"
1121           is used.
1122
1123       [!] --rateest-lt
1124           Match if rate is less than given rate/estimator.
1125
1126       [!] --rateest-gt
1127           Match if rate is greater than given rate/estimator.
1128
1129       [!] --rateest-eq
1130           Match if rate is equal to given rate/estimator.
1131
1132       In  the  so-called "absolute mode", only one rate estimator is used and
1133       compared against a static value, while in "relative mode", two rate es‐
1134       timators are compared against another.
1135
1136       --rateest name
1137              Name of the one rate estimator for absolute mode.
1138
1139       --rateest1 name
1140
1141       --rateest2 name
1142              The names of the two rate estimators for relative mode.
1143
1144       --rateest-bps [value]
1145
1146       --rateest-pps [value]
1147
1148       --rateest-bps1 [value]
1149
1150       --rateest-bps2 [value]
1151
1152       --rateest-pps1 [value]
1153
1154       --rateest-pps2 [value]
1155              Compare  the  estimator(s)  by  bytes or packets per second, and
1156              compare against the chosen value. See the above bullet list  for
1157              which  option  is to be used in which case. A unit suffix may be
1158              used - available ones  are:  bit,  [kmgt]bit,  [KMGT]ibit,  Bps,
1159              [KMGT]Bps, [KMGT]iBps.
1160
1161       Example:  This  is  what can be used to route outgoing data connections
1162       from an FTP server over two lines based on the available  bandwidth  at
1163       the time the data connection was started:
1164
1165       # Estimate outgoing rates
1166
1167       iptables  -t  mangle  -A  POSTROUTING -o eth0 -j RATEEST --rateest-name
1168       eth0 --rateest-interval 250ms --rateest-ewma 0.5s
1169
1170       iptables -t mangle -A POSTROUTING -o  ppp0  -j  RATEEST  --rateest-name
1171       ppp0 --rateest-interval 250ms --rateest-ewma 0.5s
1172
1173       # Mark based on available bandwidth
1174
1175       iptables  -t  mangle  -A  balance  -m conntrack --ctstate NEW -m helper
1176       --helper ftp -m rateest --rateest-delta --rateest1 eth0  --rateest-bps1
1177       2.5mbit  --rateest-gt  --rateest2 ppp0 --rateest-bps2 2mbit -j CONNMARK
1178       --set-mark 1
1179
1180       iptables -t mangle -A balance -m  conntrack  --ctstate  NEW  -m  helper
1181       --helper  ftp -m rateest --rateest-delta --rateest1 ppp0 --rateest-bps1
1182       2mbit --rateest-gt --rateest2 eth0 --rateest-bps2 2.5mbit  -j  CONNMARK
1183       --set-mark 2
1184
1185       iptables -t mangle -A balance -j CONNMARK --restore-mark
1186
1187   realm (IPv4-specific)
1188       This  matches  the  routing  realm.  Routing realms are used in complex
1189       routing setups involving dynamic routing protocols like BGP.
1190
1191       [!] --realm value[/mask]
1192              Matches a given realm number (and optionally  mask).  If  not  a
1193              number,  value can be a named realm from /etc/iproute2/rt_realms
1194              (mask can not be used in that case).  Both value  and  mask  are
1195              four byte unsigned integers and may be specified in decimal, hex
1196              (by prefixing with "0x") or octal (if a leading zero is given).
1197
1198   recent
1199       Allows you to dynamically create a list of IP addresses and then  match
1200       against that list in a few different ways.
1201
1202       For example, you can create a "badguy" list out of people attempting to
1203       connect to port 139 on your firewall and then DROP all  future  packets
1204       from them without considering them.
1205
1206       --set, --rcheck, --update and --remove are mutually exclusive.
1207
1208       --name name
1209              Specify  the  list  to use for the commands. If no name is given
1210              then DEFAULT will be used.
1211
1212       [!] --set
1213              This will add the source address of the packet to the  list.  If
1214              the  source address is already in the list, this will update the
1215              existing entry. This will always return success (or failure if !
1216              is passed in).
1217
1218       --rsource
1219              Match/save  the source address of each packet in the recent list
1220              table. This is the default.
1221
1222       --rdest
1223              Match/save the destination address of each packet in the  recent
1224              list table.
1225
1226       --mask netmask
1227              Netmask that will be applied to this recent list.
1228
1229       [!] --rcheck
1230              Check  if  the  source address of the packet is currently in the
1231              list.
1232
1233       [!] --update
1234              Like --rcheck, except it will update the "last  seen"  timestamp
1235              if it matches.
1236
1237       [!] --remove
1238              Check  if  the  source address of the packet is currently in the
1239              list and if so that address will be removed from  the  list  and
1240              the rule will return true. If the address is not found, false is
1241              returned.
1242
1243       --seconds seconds
1244              This option must be used in conjunction with one of --rcheck  or
1245              --update.  When  used, this will narrow the match to only happen
1246              when the address is in the list and was  seen  within  the  last
1247              given number of seconds.
1248
1249       --reap This  option  can  only  be  used in conjunction with --seconds.
1250              When used, this will cause entries older  than  the  last  given
1251              number of seconds to be purged.
1252
1253       --hitcount hits
1254              This  option must be used in conjunction with one of --rcheck or
1255              --update. When used, this will narrow the match to  only  happen
1256              when  the  address  is in the list and packets had been received
1257              greater than or equal to the given value.  This  option  may  be
1258              used  along  with --seconds to create an even narrower match re‐
1259              quiring a certain number of hits within a specific  time  frame.
1260              The  maximum  value  for  the hitcount parameter is given by the
1261              "ip_pkt_list_tot" parameter of the xt_recent kernel module.  Ex‐
1262              ceeding this value on the command line will cause the rule to be
1263              rejected.
1264
1265       --rttl This option may only be used in conjunction with one of --rcheck
1266              or  --update. When used, this will narrow the match to only hap‐
1267              pen when the address is in the list and the TTL of  the  current
1268              packet matches that of the packet which hit the --set rule. This
1269              may be useful if you have  problems  with  people  faking  their
1270              source  address in order to DoS you via this module by disallow‐
1271              ing others access to your site by sending bogus packets to you.
1272
1273       Examples:
1274
1275              iptables -A FORWARD -m recent --name badguy  --rcheck  --seconds
1276              60 -j DROP
1277
1278              iptables  -A FORWARD -p tcp -i eth0 --dport 139 -m recent --name
1279              badguy --set -j DROP
1280
1281       /proc/net/xt_recent/* are the current lists of addresses  and  informa‐
1282       tion about each entry of each list.
1283
1284       Each  file  in /proc/net/xt_recent/ can be read from to see the current
1285       list or written two using the following commands to modify the list:
1286
1287       echo +addr >/proc/net/xt_recent/DEFAULT
1288              to add addr to the DEFAULT list
1289
1290       echo -addr >/proc/net/xt_recent/DEFAULT
1291              to remove addr from the DEFAULT list
1292
1293       echo / >/proc/net/xt_recent/DEFAULT
1294              to flush the DEFAULT list (remove all entries).
1295
1296       The module itself accepts parameters, defaults shown:
1297
1298       ip_list_tot=100
1299              Number of addresses remembered per table.
1300
1301       ip_pkt_list_tot=20
1302              Number of packets per address remembered.
1303
1304       ip_list_hash_size=0
1305              Hash table size. 0 means to calculate it based  on  ip_list_tot,
1306              default: 512.
1307
1308       ip_list_perms=0644
1309              Permissions for /proc/net/xt_recent/* files.
1310
1311       ip_list_uid=0
1312              Numerical UID for ownership of /proc/net/xt_recent/* files.
1313
1314       ip_list_gid=0
1315              Numerical GID for ownership of /proc/net/xt_recent/* files.
1316
1317   rpfilter
1318       Performs  a  reverse  path  filter test on a packet.  If a reply to the
1319       packet would be sent via the same interface that the packet arrived on,
1320       the  packet  will  match.   Note  that, unlike the in-kernel rp_filter,
1321       packets protected by IPSec are not  treated  specially.   Combine  this
1322       match  with  the policy match if you want this.  Also, packets arriving
1323       via the loopback interface are always permitted.  This match  can  only
1324       be used in the PREROUTING chain of the raw or mangle table.
1325
1326       --loose
1327              Used  to  specify that the reverse path filter test should match
1328              even if the selected output device is not the expected one.
1329
1330       --validmark
1331              Also use the packets' nfmark value when performing  the  reverse
1332              path route lookup.
1333
1334       --accept-local
1335              This will permit packets arriving from the network with a source
1336              address that is also assigned to the local machine.
1337
1338       --invert
1339              This will invert the sense of the match.   Instead  of  matching
1340              packets  that  passed  the reverse path filter test, match those
1341              that have failed it.
1342
1343       Example to log and drop packets failing the reverse path filter test:
1344
1345       iptables -t raw -N RPFILTER
1346
1347       iptables -t raw -A RPFILTER -m rpfilter -j RETURN
1348
1349       iptables -t raw  -A  RPFILTER  -m  limit  --limit  10/minute  -j  NFLOG
1350       --nflog-prefix "rpfilter drop"
1351
1352       iptables -t raw -A RPFILTER -j DROP
1353
1354       iptables -t raw -A PREROUTING -j RPFILTER
1355
1356       Example to drop failed packets, without logging:
1357
1358       iptables -t raw -A RPFILTER -m rpfilter --invert -j DROP
1359
1360   rt (IPv6-specific)
1361       Match on IPv6 routing header
1362
1363       [!] --rt-type type
1364              Match the type (numeric).
1365
1366       [!] --rt-segsleft num[:num]
1367              Match the `segments left' field (range).
1368
1369       [!] --rt-len length
1370              Match the length of this header.
1371
1372       --rt-0-res
1373              Match the reserved field, too (type=0)
1374
1375       --rt-0-addrs addr[,addr...]
1376              Match type=0 addresses (list).
1377
1378       --rt-0-not-strict
1379              List of type=0 addresses is not a strict list.
1380
1381   sctp
1382       This module matches Stream Control Transmission Protocol headers.
1383
1384       [!] --source-port,--sport port[:port]
1385
1386       [!] --destination-port,--dport port[:port]
1387
1388       [!] --chunk-types {all|any|only} chunktype[:flags] [...]
1389              The  flag  letter  in  upper  case indicates that the flag is to
1390              match if set, in the lower case indicates to match if unset.
1391
1392              Chunk types: DATA INIT  INIT_ACK  SACK  HEARTBEAT  HEARTBEAT_ACK
1393              ABORT   SHUTDOWN   SHUTDOWN_ACK   ERROR  COOKIE_ECHO  COOKIE_ACK
1394              ECN_ECNE ECN_CWR SHUTDOWN_COMPLETE ASCONF ASCONF_ACK FORWARD_TSN
1395
1396              chunk type            available flags
1397              DATA                  I U B E i u b e
1398              ABORT                 T t
1399              SHUTDOWN_COMPLETE     T t
1400
1401              (lowercase means flag should be "off", uppercase means "on")
1402
1403       Examples:
1404
1405       iptables -A INPUT -p sctp --dport 80 -j DROP
1406
1407       iptables -A INPUT -p sctp --chunk-types any DATA,INIT -j DROP
1408
1409       iptables -A INPUT -p sctp --chunk-types any DATA:Be -j ACCEPT
1410
1411   set
1412       This module matches IP sets which can be defined by ipset(8).
1413
1414       [!] --match-set setname flag[,flag]...
1415              where flags are the comma separated list of src and/or dst spec‐
1416              ifications  and there can be no more than six of them. Hence the
1417              command
1418
1419               iptables -A FORWARD -m set --match-set test src,dst
1420
1421              will match packets, for which (if the set type is ipportmap) the
1422              source  address  and  destination  port pair can be found in the
1423              specified set. If the set type of the specified  set  is  single
1424              dimension (for example ipmap), then the command will match pack‐
1425              ets for which the source address can be found in  the  specified
1426              set.
1427
1428       --return-nomatch
1429              If  the  --return-nomatch  option  is specified and the set type
1430              supports the nomatch flag, then  the  matching  is  reversed:  a
1431              match with an element flagged with nomatch returns true, while a
1432              match with a plain element returns false.
1433
1434       ! --update-counters
1435              If the --update-counters flag is negated, then  the  packet  and
1436              byte  counters  of  the matching element in the set won't be up‐
1437              dated. Default the packet and byte counters are updated.
1438
1439       ! --update-subcounters
1440              If the --update-subcounters flag is negated, then the packet and
1441              byte  counters  of  the  matching element in the member set of a
1442              list type of set won't be updated. Default the packet  and  byte
1443              counters are updated.
1444
1445       [!] --packets-eq value
1446              If  the  packet  is matched an element in the set, match only if
1447              the packet counter of the element matches the given value too.
1448
1449       --packets-lt value
1450              If the packet is matched an element in the set,  match  only  if
1451              the  packet  counter of the element is less than the given value
1452              as well.
1453
1454       --packets-gt value
1455              If the packet is matched an element in the set,  match  only  if
1456              the  packet  counter  of  the  element is greater than the given
1457              value as well.
1458
1459       [!] --bytes-eq value
1460              If the packet is matched an element in the set,  match  only  if
1461              the byte counter of the element matches the given value too.
1462
1463       --bytes-lt value
1464              If  the  packet  is matched an element in the set, match only if
1465              the byte counter of the element is less than the given value  as
1466              well.
1467
1468       --bytes-gt value
1469              If  the  packet  is matched an element in the set, match only if
1470              the byte counter of the element is greater than the given  value
1471              as well.
1472
1473       The packet and byte counters related options and flags are ignored when
1474       the set was defined without counter support.
1475
1476       The option --match-set can be replaced by --set if that does not  clash
1477       with an option of other extensions.
1478
1479       Use  of  -m  set requires that ipset kernel support is provided, which,
1480       for standard kernels, is the case since Linux 2.6.39.
1481
1482   socket
1483       This matches if an open TCP/UDP socket can be found by doing  a  socket
1484       lookup on the packet. It matches if there is an established or non-zero
1485       bound listening socket (possibly with a non-local address). The  lookup
1486       is performed using the packet tuple of TCP/UDP packets, or the original
1487       TCP/UDP header embedded in an ICMP/ICPMv6 error packet.
1488
1489       --transparent
1490              Ignore non-transparent sockets.
1491
1492       --nowildcard
1493              Do not ignore sockets bound to 'any' address.  The socket  match
1494              won't  accept  zero-bound listeners by default, since then local
1495              services could intercept traffic that would  otherwise  be  for‐
1496              warded.   This  option  therefore has security implications when
1497              used to match traffic being forwarded to redirect  such  packets
1498              to  local  machine  with  policy routing.  When using the socket
1499              match to implement fully transparent proxies bound to  non-local
1500              addresses  it is recommended to use the --transparent option in‐
1501              stead.
1502
1503       Example (assuming packets with mark 1 are delivered locally):
1504
1505              -t  mangle  -A  PREROUTING  -m  socket  --transparent  -j   MARK
1506              --set-mark 1
1507
1508       --restore-skmark
1509              Set  the  packet mark to the matching socket's mark. Can be com‐
1510              bined with the --transparent and  --nowildcard  options  to  re‐
1511              strict the sockets to be matched when restoring the packet mark.
1512
1513       Example:  An  application  opens 2 transparent (IP_TRANSPARENT) sockets
1514       and sets a mark on them with  SO_MARK  socket  option.  We  can  filter
1515       matching packets:
1516
1517              -t mangle -I PREROUTING -m socket --transparent --restore-skmark
1518              -j action
1519
1520              -t mangle -A action -m mark --mark 10 -j action2
1521
1522              -t mangle -A action -m mark --mark 11 -j action3
1523
1524   state
1525       The "state" extension is a subset of the "conntrack"  module.   "state"
1526       allows access to the connection tracking state for this packet.
1527
1528       [!] --state state
1529              Where  state  is a comma separated list of the connection states
1530              to match. Only a subset of the states unterstood by  "conntrack"
1531              are recognized: INVALID, ESTABLISHED, NEW, RELATED or UNTRACKED.
1532              For their description, see the "conntrack" heading in this  man‐
1533              page.
1534
1535   statistic
1536       This module matches packets based on some statistic condition.  It sup‐
1537       ports two distinct modes settable with the --mode option.
1538
1539       Supported options:
1540
1541       --mode mode
1542              Set the matching mode of the matching rule, supported modes  are
1543              random and nth.
1544
1545       [!] --probability p
1546              Set the probability for a packet to be randomly matched. It only
1547              works with the random mode. p must be within 0.0  and  1.0.  The
1548              supported granularity is in 1/2147483648th increments.
1549
1550       [!] --every n
1551              Match  one  packet  every nth packet. It works only with the nth
1552              mode (see also the --packet option).
1553
1554       --packet p
1555              Set the initial counter value (0 <= p <= n-1, default 0) for the
1556              nth mode.
1557
1558   string
1559       This  module  matches  a  given  string  by using some pattern matching
1560       strategy. It requires a linux kernel >= 2.6.14.
1561
1562       --algo {bm|kmp}
1563              Select the pattern matching strategy. (bm = Boyer-Moore,  kmp  =
1564              Knuth-Pratt-Morris)
1565
1566       --from offset
1567              Set the offset from which it starts looking for any matching. If
1568              not passed, default is 0.
1569
1570       --to offset
1571              Set the offset up to which should be scanned. That is, byte off‐
1572              set-1 (counting from 0) is the last one that is scanned.  If not
1573              passed, default is the packet size.
1574
1575       [!] --string pattern
1576              Matches the given pattern.
1577
1578       [!] --hex-string pattern
1579              Matches the given pattern in hex notation.
1580
1581       --icase
1582              Ignore case when searching.
1583
1584       Examples:
1585
1586              # The string pattern can be used for simple text characters.
1587              iptables -A INPUT -p tcp --dport 80 -m string --algo bm --string
1588              'GET /index.html' -j LOG
1589
1590              #  The  hex string pattern can be used for non-printable charac‐
1591              ters, like |0D 0A| or |0D0A|.
1592              iptables -p udp --dport 53 -m string --algo bm --from 40 --to 57
1593              --hex-string '|03|www|09|netfilter|03|org|00|'
1594
1595   tcp
1596       These  extensions can be used if `--protocol tcp' is specified. It pro‐
1597       vides the following options:
1598
1599       [!] --source-port,--sport port[:port]
1600              Source port or port range specification. This can  either  be  a
1601              service  name  or  a port number. An inclusive range can also be
1602              specified, using the format first:last.  If the  first  port  is
1603              omitted,  "0" is assumed; if the last is omitted, "65535" is as‐
1604              sumed.  The flag --sport is a convenient alias for this option.
1605
1606       [!] --destination-port,--dport port[:port]
1607              Destination port or port range specification.  The flag  --dport
1608              is a convenient alias for this option.
1609
1610       [!] --tcp-flags mask comp
1611              Match  when  the TCP flags are as specified.  The first argument
1612              mask is the flags which we should examine, written as  a  comma-
1613              separated  list,  and  the second argument comp is a comma-sepa‐
1614              rated list of flags which must be set.  Flags are: SYN  ACK  FIN
1615              RST URG PSH ALL NONE.  Hence the command
1616               iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
1617              will  only match packets with the SYN flag set, and the ACK, FIN
1618              and RST flags unset.
1619
1620       [!] --syn
1621              Only match TCP packets with the SYN bit set and the ACK,RST  and
1622              FIN  bits cleared.  Such packets are used to request TCP connec‐
1623              tion initiation; for example, blocking such packets coming in an
1624              interface  will  prevent  incoming TCP connections, but outgoing
1625              TCP  connections  will  be  unaffected.   It  is  equivalent  to
1626              --tcp-flags  SYN,RST,ACK,FIN  SYN.  If the "!" flag precedes the
1627              "--syn", the sense of the option is inverted.
1628
1629       [!] --tcp-option number
1630              Match if TCP option set.
1631
1632   tcpmss
1633       This matches the TCP MSS  (maximum  segment  size)  field  of  the  TCP
1634       header.  You can only use this on TCP SYN or SYN/ACK packets, since the
1635       MSS is only negotiated during the TCP handshake at  connection  startup
1636       time.
1637
1638       [!] --mss value[:value]
1639              Match  a  given TCP MSS value or range. If a range is given, the
1640              second value must be greater than or equal to the first value.
1641
1642   time
1643       This matches if the packet arrival time/date is within a  given  range.
1644       All  options  are optional, but are ANDed when specified. All times are
1645       interpreted as UTC by default.
1646
1647       --datestart YYYY[-MM[-DD[Thh[:mm[:ss]]]]]
1648
1649       --datestop YYYY[-MM[-DD[Thh[:mm[:ss]]]]]
1650              Only match during the given time, which must be in ISO 8601  "T"
1651              notation.   The  possible  time  range is 1970-01-01T00:00:00 to
1652              2038-01-19T04:17:07.
1653
1654              If --datestart or --datestop are not specified, it will  default
1655              to 1970-01-01 and 2038-01-19, respectively.
1656
1657       --timestart hh:mm[:ss]
1658
1659       --timestop hh:mm[:ss]
1660              Only  match during the given daytime. The possible time range is
1661              00:00:00 to 23:59:59. Leading zeroes are allowed (e.g.  "06:03")
1662              and correctly interpreted as base-10.
1663
1664       [!] --monthdays day[,day...]
1665              Only match on the given days of the month. Possible values are 1
1666              to 31. Note that specifying 31  will  of  course  not  match  on
1667              months  which  do  not have a 31st day; the same goes for 28- or
1668              29-day February.
1669
1670       [!] --weekdays day[,day...]
1671              Only match on the given weekdays. Possible values are Mon,  Tue,
1672              Wed,  Thu,  Fri,  Sat, Sun, or values from 1 to 7, respectively.
1673              You may also use two-character variants (Mo, Tu, etc.).
1674
1675       --contiguous
1676              When --timestop is smaller than --timestart value, match this as
1677              a single time period instead distinct intervals.  See EXAMPLES.
1678
1679       --kerneltz
1680              Use  the  kernel  timezone instead of UTC to determine whether a
1681              packet meets the time regulations.
1682
1683       About kernel timezones: Linux keeps the system time in UTC, and  always
1684       does  so.   On boot, system time is initialized from a referential time
1685       source. Where this time source has no timezone information, such as the
1686       x86 CMOS RTC, UTC will be assumed. If the time source is however not in
1687       UTC, userspace should provide the correct system time and  timezone  to
1688       the kernel once it has the information.
1689
1690       Local  time  is  a  feature on top of the (timezone independent) system
1691       time. Each process has its own idea of local time, specified via the TZ
1692       environment variable. The kernel also has its own timezone offset vari‐
1693       able. The TZ userspace environment variable specifies how the UTC-based
1694       system time is displayed, e.g. when you run date(1), or what you see on
1695       your desktop clock.  The TZ string may resolve to different offsets  at
1696       different  dates,  which  is what enables the automatic time-jumping in
1697       userspace. when DST changes. The kernel's timezone offset  variable  is
1698       used  when  it  has  to  convert  between  non-UTC sources, such as FAT
1699       filesystems, to UTC (since the latter is what the rest  of  the  system
1700       uses).
1701
1702       The caveat with the kernel timezone is that Linux distributions may ig‐
1703       nore to set the kernel timezone, and instead only set the system  time.
1704       Even  if a particular distribution does set the timezone at boot, it is
1705       usually does not keep the  kernel  timezone  offset  -  which  is  what
1706       changes  on DST - up to date.  ntpd will not touch the kernel timezone,
1707       so running it will not resolve the issue. As such, one may encounter  a
1708       timezone that is always +0000, or one that is wrong half of the time of
1709       the year. As such, using --kerneltz is highly discouraged.
1710
1711       EXAMPLES. To match on weekends, use:
1712
1713              -m time --weekdays Sa,Su
1714
1715       Or, to match (once) on a national holiday block:
1716
1717              -m time --datestart 2007-12-24 --datestop 2007-12-27
1718
1719       Since the stop time is actually inclusive, you would need the following
1720       stop time to not match the first second of the new day:
1721
1722              -m      time     --datestart     2007-01-01T17:00     --datestop
1723              2007-01-01T23:59:59
1724
1725       During lunch hour:
1726
1727              -m time --timestart 12:30 --timestop 13:30
1728
1729       The fourth Friday in the month:
1730
1731              -m time --weekdays Fr --monthdays 22,23,24,25,26,27,28
1732
1733       (Note that this exploits a certain mathematical  property.  It  is  not
1734       possible  to  say "fourth Thursday OR fourth Friday" in one rule. It is
1735       possible with multiple rules, though.)
1736
1737       Matching across days might not do what is expected.  For instance,
1738
1739              -m time --weekdays Mo --timestart 23:00  --timestop  01:00  Will
1740              match  Monday,  for  one  hour from midnight to 1 a.m., and then
1741              again for another hour from 23:00 onwards.  If this is unwanted,
1742              e.g.  if  you  would like 'match for two hours from Montay 23:00
1743              onwards' you need to also specify the --contiguous option in the
1744              example above.
1745
1746   tos
1747       This  module matches the 8-bit Type of Service field in the IPv4 header
1748       (i.e.  including the "Precedence" bits) or the  (also  8-bit)  Priority
1749       field in the IPv6 header.
1750
1751       [!] --tos value[/mask]
1752              Matches  packets  with  the  given  TOS mark value. If a mask is
1753              specified, it is logically ANDed with the TOS  mark  before  the
1754              comparison.
1755
1756       [!] --tos symbol
1757              You  can  specify  a  symbolic name when using the tos match for
1758              IPv4. The list of recognized TOS names can be obtained by  call‐
1759              ing  iptables  with -m tos -h.  Note that this implies a mask of
1760              0x3F, i.e. all but the ECN bits.
1761
1762   ttl (IPv4-specific)
1763       This module matches the time to live field in the IP header.
1764
1765       [!] --ttl-eq ttl
1766              Matches the given TTL value.
1767
1768       --ttl-gt ttl
1769              Matches if TTL is greater than the given TTL value.
1770
1771       --ttl-lt ttl
1772              Matches if TTL is less than the given TTL value.
1773
1774   u32
1775       U32 tests whether quantities of up to 4 bytes extracted from  a  packet
1776       have  specified values. The specification of what to extract is general
1777       enough to find data at given offsets from tcp headers or payloads.
1778
1779       [!] --u32 tests
1780              The argument amounts to a program in a small language  described
1781              below.
1782
1783              tests := location "=" value | tests "&&" location "=" value
1784
1785              value := range | value "," range
1786
1787              range := number | number ":" number
1788
1789       a  single number, n, is interpreted the same as n:n. n:m is interpreted
1790       as the range of numbers >=n and <=m.
1791
1792           location := number | location operator number
1793
1794           operator := "&" | "<<" | ">>" | "@"
1795
1796       The operators &, <<, >> and && mean the same as in C.  The = is  really
1797       a  set  membership operator and the value syntax describes a set. The @
1798       operator is what allows moving to the next header and is described fur‐
1799       ther below.
1800
1801       There  are  currently some artificial implementation limits on the size
1802       of the tests:
1803
1804           *  no more than 10 of "=" (and 9 "&&"s) in the u32 argument
1805
1806           *  no more than 10 ranges (and 9 commas) per value
1807
1808           *  no more than 10 numbers (and 9 operators) per location
1809
1810       To describe the meaning of location, imagine the following machine that
1811       interprets it. There are three registers:
1812
1813              A is of type char *, initially the address of the IP header
1814
1815              B and C are unsigned 32 bit integers, initially zero
1816
1817       The instructions are:
1818
1819       number B = number;
1820
1821              C = (*(A+B)<<24) + (*(A+B+1)<<16) + (*(A+B+2)<<8) + *(A+B+3)
1822
1823       &number
1824              C = C & number
1825
1826       << number
1827              C = C << number
1828
1829       >> number
1830              C = C >> number
1831
1832       @number
1833              A = A + C; then do the instruction number
1834
1835       Any  access  of memory outside [skb->data,skb->end] causes the match to
1836       fail.  Otherwise the result of the computation is the final value of C.
1837
1838       Whitespace is allowed but not required in the tests. However, the char‐
1839       acters  that  do occur there are likely to require shell quoting, so it
1840       is a good idea to enclose the arguments in quotes.
1841
1842       Example:
1843
1844              match IP packets with total length >= 256
1845
1846              The IP header contains a total length field in bytes 2-3.
1847
1848              --u32 "0 & 0xFFFF = 0x100:0xFFFF"
1849
1850              read bytes 0-3
1851
1852              AND that with 0xFFFF (giving bytes 2-3), and test  whether  that
1853              is in the range [0x100:0xFFFF]
1854
1855       Example: (more realistic, hence more complicated)
1856
1857              match ICMP packets with icmp type 0
1858
1859              First test that it is an ICMP packet, true iff byte 9 (protocol)
1860              = 1
1861
1862              --u32 "6 & 0xFF = 1 && ...
1863
1864              read bytes 6-9, use & to throw away bytes 6-8  and  compare  the
1865              result  to  1.  Next  test that it is not a fragment. (If so, it
1866              might be part of such a packet but we cannot always tell.) N.B.:
1867              This  test is generally needed if you want to match anything be‐
1868              yond the IP header. The last 6 bits of byte 6 and all of byte  7
1869              are  0  iff this is a complete packet (not a fragment). Alterna‐
1870              tively, you can allow first fragments by only testing the last 5
1871              bits of byte 6.
1872
1873               ... 4 & 0x3FFF = 0 && ...
1874
1875              Last  test:  the  first byte past the IP header (the type) is 0.
1876              This is where we have to use the @syntax. The length of  the  IP
1877              header (IHL) in 32 bit words is stored in the right half of byte
1878              0 of the IP header itself.
1879
1880               ... 0 >> 22 & 0x3C @ 0 >> 24 = 0"
1881
1882              The first 0 means read bytes 0-3, >>22 means shift that 22  bits
1883              to  the  right.  Shifting  24 bits would give the first byte, so
1884              only 22 bits is four times that plus a few more bits.  &3C  then
1885              eliminates  the  two  extra bits on the right and the first four
1886              bits of the first byte. For instance,  if  IHL=5,  then  the  IP
1887              header is 20 (4 x 5) bytes long. In this case, bytes 0-1 are (in
1888              binary)  xxxx0101  yyzzzzzz,  >>22  gives  the  10   bit   value
1889              xxxx0101yy and &3C gives 010100. @ means to use this number as a
1890              new offset into the packet, and read four  bytes  starting  from
1891              there.  This  is the first 4 bytes of the ICMP payload, of which
1892              byte 0 is the ICMP type. Therefore, we simply shift the value 24
1893              to the right to throw out all but the first byte and compare the
1894              result with 0.
1895
1896       Example:
1897
1898              TCP payload bytes 8-12 is any of 1, 2, 5 or 8
1899
1900              First we test that the packet is a tcp packet (similar to ICMP).
1901
1902              --u32 "6 & 0xFF = 6 && ...
1903
1904              Next, test that it is not a fragment (same as above).
1905
1906               ... 0 >> 22 & 0x3C @ 12 >> 26 & 0x3C @ 8 = 1,2,5,8"
1907
1908              0>>22&3C as above computes the number of bytes in the IP header.
1909              @  makes this the new offset into the packet, which is the start
1910              of the TCP header. The length of the TCP header (again in 32 bit
1911              words)  is  the  left  half  of  byte  12 of the TCP header. The
1912              12>>26&3C computes this length  in  bytes  (similar  to  the  IP
1913              header  before).  "@"  makes  this  the new offset, which is the
1914              start of the TCP payload. Finally, 8 reads  bytes  8-12  of  the
1915              payload and = checks whether the result is any of 1, 2, 5 or 8.
1916
1917   udp
1918       These  extensions can be used if `--protocol udp' is specified. It pro‐
1919       vides the following options:
1920
1921       [!] --source-port,--sport port[:port]
1922              Source port or port range specification.  See the description of
1923              the --source-port option of the TCP extension for details.
1924
1925       [!] --destination-port,--dport port[:port]
1926              Destination  port or port range specification.  See the descrip‐
1927              tion of the --destination-port option of the TCP  extension  for
1928              details.
1929

TARGET EXTENSIONS

1931       iptables can use extended target modules: the following are included in
1932       the standard distribution.
1933
1934   AUDIT
1935       This target creates audit records for packets hitting the  target.   It
1936       can  be used to record accepted, dropped, and rejected packets. See au‐
1937       ditd(8) for additional details.
1938
1939       --type {accept|drop|reject}
1940              Set type of audit record. Starting with linux-4.12, this  option
1941              has  no  effect on generated audit messages anymore. It is still
1942              accepted by iptables for compatibility reasons, but ignored.
1943
1944       Example:
1945
1946              iptables -N AUDIT_DROP
1947
1948              iptables -A AUDIT_DROP -j AUDIT
1949
1950              iptables -A AUDIT_DROP -j DROP
1951
1952   CHECKSUM
1953       This target selectively works around broken/old applications.   It  can
1954       only be used in the mangle table.
1955
1956       --checksum-fill
1957              Compute and fill in the checksum in a packet that lacks a check‐
1958              sum.  This is particularly useful, if you need  to  work  around
1959              old  applications  such  as  dhcp clients, that do not work well
1960              with checksum offloads, but don't want to disable checksum  off‐
1961              load in your device.
1962
1963   CLASSIFY
1964       This  module  allows you to set the skb->priority value (and thus clas‐
1965       sify the packet into a specific CBQ class).
1966
1967       --set-class major:minor
1968              Set the major and minor class value. The values are  always  in‐
1969              terpreted as hexadecimal even if no 0x prefix is given.
1970
1971   CLUSTERIP (IPv4-specific)
1972       This  module  allows  you  to  configure a simple cluster of nodes that
1973       share a certain IP and MAC address without an explicit load balancer in
1974       front  of  them.   Connections  are  statically distributed between the
1975       nodes in this cluster.
1976
1977       Please note that CLUSTERIP target is considered deprecated in favour of
1978       cluster match which is more flexible and not limited to IPv4.
1979
1980       --new  Create  a  new  ClusterIP.   You  always have to set this on the
1981              first rule for a given ClusterIP.
1982
1983       --hashmode mode
1984              Specify the hashing mode.  Has to  be  one  of  sourceip,  sour‐
1985              ceip-sourceport, sourceip-sourceport-destport.
1986
1987       --clustermac mac
1988              Specify the ClusterIP MAC address. Has to be a link-layer multi‐
1989              cast address
1990
1991       --total-nodes num
1992              Number of total nodes within this cluster.
1993
1994       --local-node num
1995              Local node number within this cluster.
1996
1997       --hash-init rnd
1998              Specify the random seed used for hash initialization.
1999
2000   CONNMARK
2001       This module sets the netfilter mark value associated with a connection.
2002       The mark is 32 bits wide.
2003
2004       --set-xmark value[/mask]
2005              Zero out the bits given by mask and XOR value into the ctmark.
2006
2007       --save-mark [--nfmask nfmask] [--ctmask ctmask]
2008              Copy  the  packet  mark (nfmark) to the connection mark (ctmark)
2009              using the given masks. The new nfmark  value  is  determined  as
2010              follows:
2011
2012              ctmark = (ctmark & ~ctmask) ^ (nfmark & nfmask)
2013
2014              i.e.  ctmask  defines what bits to clear and nfmask what bits of
2015              the nfmark to XOR into the ctmark. ctmask and nfmask default  to
2016              0xFFFFFFFF.
2017
2018       --restore-mark [--nfmask nfmask] [--ctmask ctmask]
2019              Copy  the  connection  mark (ctmark) to the packet mark (nfmark)
2020              using the given masks. The new ctmark  value  is  determined  as
2021              follows:
2022
2023              nfmark = (nfmark & ~nfmask) ^ (ctmark & ctmask);
2024
2025              i.e.  nfmask  defines what bits to clear and ctmask what bits of
2026              the ctmark to XOR into the nfmark. ctmask and nfmask default  to
2027              0xFFFFFFFF.
2028
2029              --restore-mark is only valid in the mangle table.
2030
2031       The following mnemonics are available for --set-xmark:
2032
2033       --and-mark bits
2034              Binary AND the ctmark with bits. (Mnemonic for --set-xmark 0/in‐
2035              vbits, where invbits is the binary negation of bits.)
2036
2037       --or-mark bits
2038              Binary OR  the  ctmark  with  bits.  (Mnemonic  for  --set-xmark
2039              bits/bits.)
2040
2041       --xor-mark bits
2042              Binary  XOR  the  ctmark  with  bits.  (Mnemonic for --set-xmark
2043              bits/0.)
2044
2045       --set-mark value[/mask]
2046              Set the connection mark. If a mask is specified then only  those
2047              bits set in the mask are modified.
2048
2049       --save-mark [--mask mask]
2050              Copy  the  nfmark  to  the  ctmark. If a mask is specified, only
2051              those bits are copied.
2052
2053       --restore-mark [--mask mask]
2054              Copy the ctmark to the nfmark. If  a  mask  is  specified,  only
2055              those bits are copied. This is only valid in the mangle table.
2056
2057   CONNSECMARK
2058       This  module  copies  security markings from packets to connections (if
2059       unlabeled), and from connections back to packets (also  only  if  unla‐
2060       beled).  Typically used in conjunction with SECMARK, it is valid in the
2061       security table (for backwards compatibility with older kernels,  it  is
2062       also valid in the mangle table).
2063
2064       --save If  the packet has a security marking, copy it to the connection
2065              if the connection is not marked.
2066
2067       --restore
2068              If the packet does not have a security marking, and the  connec‐
2069              tion  does, copy the security marking from the connection to the
2070              packet.
2071
2072
2073   CT
2074       The CT target sets parameters for a packet or  its  associated  connec‐
2075       tion. The target attaches a "template" connection tracking entry to the
2076       packet, which is then used by the conntrack core  when  initializing  a
2077       new ct entry. This target is thus only valid in the "raw" table.
2078
2079       --notrack
2080              Disables connection tracking for this packet.
2081
2082       --helper name
2083              Use  the  helper  identified by name for the connection. This is
2084              more flexible than loading the  conntrack  helper  modules  with
2085              preset ports.
2086
2087       --ctevents event[,...]
2088              Only  generate  the  specified conntrack events for this connec‐
2089              tion. Possible event types are: new,  related,  destroy,  reply,
2090              assured, protoinfo, helper, mark (this refers to the ctmark, not
2091              nfmark), natseqinfo, secmark (ctsecmark).
2092
2093       --expevents event[,...]
2094              Only generate the specified expectation events for this  connec‐
2095              tion.  Possible event types are: new.
2096
2097       --zone-orig {id|mark}
2098              For  traffic  coming from ORIGINAL direction, assign this packet
2099              to zone id and only have lookups done in that zone. If  mark  is
2100              used instead of id, the zone is derived from the packet nfmark.
2101
2102       --zone-reply {id|mark}
2103              For  traffic  coming from REPLY direction, assign this packet to
2104              zone id and only have lookups done in that zone. If mark is used
2105              instead of id, the zone is derived from the packet nfmark.
2106
2107       --zone {id|mark}
2108              Assign this packet to zone id and only have lookups done in that
2109              zone.  If mark is used instead of id, the zone is  derived  from
2110              the  packet nfmark. By default, packets have zone 0. This option
2111              applies to both directions.
2112
2113       --timeout name
2114              Use the timeout policy identified by name  for  the  connection.
2115              This  is  provides  more flexible timeout policy definition than
2116              global  timeout  values   available   at   /proc/sys/net/netfil‐
2117              ter/nf_conntrack_*_timeout_*.
2118
2119   DNAT
2120       This  target is only valid in the nat table, in the PREROUTING and OUT‐
2121       PUT chains, and user-defined chains which are only  called  from  those
2122       chains.  It specifies that the destination address of the packet should
2123       be modified (and all future packets in this  connection  will  also  be
2124       mangled),  and rules should cease being examined.  It takes the follow‐
2125       ing options:
2126
2127       --to-destination [ipaddr[-ipaddr]][:port[-port]]
2128              which can specify a single new destination IP address, an inclu‐
2129              sive range of IP addresses. Optionally a port range, if the rule
2130              also specifies one of the following protocols: tcp, udp, dccp or
2131              sctp.   If no port range is specified, then the destination port
2132              will never be modified. If no IP address is specified then  only
2133              the  destination port will be modified.  In Kernels up to 2.6.10
2134              you can add several --to-destination options. For those kernels,
2135              if  you specify more than one destination address, either via an
2136              address range or multiple  --to-destination  options,  a  simple
2137              round-robin  (one  after  another in cycle) load balancing takes
2138              place between these addresses.  Later  Kernels  (>=  2.6.11-rc1)
2139              don't have the ability to NAT to multiple ranges anymore.
2140
2141       --random
2142              If  option --random is used then port mapping will be randomized
2143              (kernel >= 2.6.22).
2144
2145       --persistent
2146              Gives a client the  same  source-/destination-address  for  each
2147              connection.   This  supersedes the SAME target. Support for per‐
2148              sistent mappings is available from 2.6.29-rc2.
2149
2150       IPv6 support available since Linux kernels >= 3.7.
2151
2152   DNPT (IPv6-specific)
2153       Provides stateless destination IPv6-to-IPv6 Network Prefix  Translation
2154       (as described by RFC 6296).
2155
2156       You  have to use this target in the mangle table, not in the nat table.
2157       It takes the following options:
2158
2159       --src-pfx [prefix/length]
2160              Set source prefix that you want to translate and length
2161
2162       --dst-pfx [prefix/length]
2163              Set destination prefix that you want to use in  the  translation
2164              and length
2165
2166       You have to use the SNPT target to undo the translation. Example:
2167
2168              ip6tables  -t mangle -I POSTROUTING -s fd00::/64  -o vboxnet0 -j
2169              SNPT --src-pfx fd00::/64 --dst-pfx 2001:e20:2000:40f::/64
2170
2171              ip6tables   -t   mangle    -I    PREROUTING    -i    wlan0    -d
2172              2001:e20:2000:40f::/64  -j DNPT --src-pfx 2001:e20:2000:40f::/64
2173              --dst-pfx fd00::/64
2174
2175       You may need to enable IPv6 neighbor proxy:
2176
2177              sysctl -w net.ipv6.conf.all.proxy_ndp=1
2178
2179       You also have to use the NOTRACK target to disable connection  tracking
2180       for translated flows.
2181
2182   DSCP
2183       This  target alters the value of the DSCP bits within the TOS header of
2184       the IPv4 packet.  As this manipulates a packet, it can only be used  in
2185       the mangle table.
2186
2187       --set-dscp value
2188              Set the DSCP field to a numerical value (can be decimal or hex)
2189
2190       --set-dscp-class class
2191              Set the DSCP field to a DiffServ class.
2192
2193   ECN (IPv4-specific)
2194       This target selectively works around known ECN blackholes.  It can only
2195       be used in the mangle table.
2196
2197       --ecn-tcp-remove
2198              Remove all ECN bits from the TCP header.  Of course, it can only
2199              be used in conjunction with -p tcp.
2200
2201   HL (IPv6-specific)
2202       This  is  used  to  modify  the Hop Limit field in IPv6 header. The Hop
2203       Limit field is similar to what is known as TTL value in IPv4.   Setting
2204       or  incrementing the Hop Limit field can potentially be very dangerous,
2205       so it should be avoided at any cost. This target is only valid in  man‐
2206       gle table.
2207
2208       Don't  ever set or increment the value on packets that leave your local
2209       network!
2210
2211       --hl-set value
2212              Set the Hop Limit to `value'.
2213
2214       --hl-dec value
2215              Decrement the Hop Limit `value' times.
2216
2217       --hl-inc value
2218              Increment the Hop Limit `value' times.
2219
2220   HMARK
2221       Like MARK, i.e. set the fwmark, but the mark is calculated from hashing
2222       packet selector at choice. You have also to specify the mark range and,
2223       optionally, the offset to start from. ICMP error messages are inspected
2224       and used to calculate the hashing.
2225
2226       Existing options are:
2227
2228       --hmark-tuple tuple
2229              Possible  tuple  members  are: src meaning source address (IPv4,
2230              IPv6 address), dst meaning destination address (IPv4,  IPv6  ad‐
2231              dress),  sport  meaning  source  port  (TCP, UDP, UDPlite, SCTP,
2232              DCCP), dport meaning destination port (TCP, UDP, UDPlite,  SCTP,
2233              DCCP),  spi  meaning  Security Parameter Index (AH, ESP), and ct
2234              meaning the usage of the conntrack tuple instead of  the  packet
2235              selectors.
2236
2237       --hmark-mod value (must be > 0)
2238              Modulus  for  hash  calculation  (to limit the range of possible
2239              marks)
2240
2241       --hmark-offset value
2242              Offset to start marks from.
2243
2244       For advanced usage, instead of using  --hmark-tuple,  you  can  specify
2245       custom
2246              prefixes and masks:
2247
2248       --hmark-src-prefix cidr
2249              The source address mask in CIDR notation.
2250
2251       --hmark-dst-prefix cidr
2252              The destination address mask in CIDR notation.
2253
2254       --hmark-sport-mask value
2255              A 16 bit source port mask in hexadecimal.
2256
2257       --hmark-dport-mask value
2258              A 16 bit destination port mask in hexadecimal.
2259
2260       --hmark-spi-mask value
2261              A 32 bit field with spi mask.
2262
2263       --hmark-proto-mask value
2264              An 8 bit field with layer 4 protocol number.
2265
2266       --hmark-rnd value
2267              A 32 bit random custom value to feed hash calculation.
2268
2269       Examples:
2270
2271       iptables -t mangle -A PREROUTING -m conntrack --ctstate NEW
2272        -j   HMARK   --hmark-tuple   ct,src,dst,proto   --hmark-offset   10000
2273       --hmark-mod 10 --hmark-rnd 0xfeedcafe
2274
2275       iptables -t mangle -A PREROUTING -j HMARK --hmark-offset 10000 --hmark-
2276       tuple src,dst,proto --hmark-mod 10 --hmark-rnd 0xdeafbeef
2277
2278   IDLETIMER
2279       This  target can be used to identify when interfaces have been idle for
2280       a certain period of time.  Timers are identified by labels and are cre‐
2281       ated  when a rule is set with a new label.  The rules also take a time‐
2282       out value (in seconds) as an option.  If more than one  rule  uses  the
2283       same timer label, the timer will be restarted whenever any of the rules
2284       get a hit.  One entry for each timer is created in sysfs.  This  attri‐
2285       bute  contains  the  timer  remaining for the timer to expire.  The at‐
2286       tributes are located under the xt_idletimer class:
2287
2288       /sys/class/xt_idletimer/timers/<label>
2289
2290       When the timer expires, the target module sends a sysfs notification to
2291       the userspace, which can then decide what to do (eg. disconnect to save
2292       power).
2293
2294       --timeout amount
2295              This is the time in seconds that will trigger the notification.
2296
2297       --label string
2298              This is a unique identifier for the timer.  The  maximum  length
2299              for the label string is 27 characters.
2300
2301   LED
2302       This creates an LED-trigger that can then be attached to system indica‐
2303       tor lights, to blink or  illuminate  them  when  certain  packets  pass
2304       through  the  system. One example might be to light up an LED for a few
2305       minutes every time an SSH connection is made to the local machine.  The
2306       following options control the trigger behavior:
2307
2308       --led-trigger-id name
2309              This  is  the  name given to the LED trigger. The actual name of
2310              the trigger will be prefixed with "netfilter-".
2311
2312       --led-delay ms
2313              This indicates how long (in milliseconds) the LED should be left
2314              illuminated  when  a  packet  arrives  before being switched off
2315              again. The default is 0 (blink as fast as possible.) The special
2316              value  inf can be given to leave the LED on permanently once ac‐
2317              tivated. (In this case the trigger will need to be manually  de‐
2318              tached and reattached to the LED device to switch it off again.)
2319
2320       --led-always-blink
2321              Always  make the LED blink on packet arrival, even if the LED is
2322              already on.  This allows notification of new packets  even  with
2323              long delay values (which otherwise would result in a silent pro‐
2324              longing of the delay time.)
2325
2326       Example:
2327
2328       Create an LED trigger for incoming SSH traffic:
2329              iptables -A INPUT -p tcp --dport 22 -j LED --led-trigger-id ssh
2330
2331       Then attach the new trigger to an LED:
2332              echo netfilter-ssh >/sys/class/leds/ledname/trigger
2333
2334   LOG
2335       Turn on kernel logging of matching packets.  When this  option  is  set
2336       for  a rule, the Linux kernel will print some information on all match‐
2337       ing packets (like most IP/IPv6 header fields) via the kernel log (where
2338       it can be read with dmesg(1) or read in the syslog).
2339
2340       This  is  a  "non-terminating target", i.e. rule traversal continues at
2341       the next rule.  So if you want to LOG the packets you refuse,  use  two
2342       separate  rules with the same matching criteria, first using target LOG
2343       then DROP (or REJECT).
2344
2345       --log-level level
2346              Level of logging, which can be (system-specific)  numeric  or  a
2347              mnemonic.   Possible  values  are (in decreasing order of prior‐
2348              ity): emerg, alert, crit, error, warning, notice, info or debug.
2349
2350       --log-prefix prefix
2351              Prefix log messages with the specified prefix; up to 29  letters
2352              long, and useful for distinguishing messages in the logs.
2353
2354       --log-tcp-sequence
2355              Log  TCP sequence numbers. This is a security risk if the log is
2356              readable by users.
2357
2358       --log-tcp-options
2359              Log options from the TCP packet header.
2360
2361       --log-ip-options
2362              Log options from the IP/IPv6 packet header.
2363
2364       --log-uid
2365              Log the userid of the process which generated the packet.
2366
2367   MARK
2368       This target is used to set the Netfilter mark value associated with the
2369       packet.  It can, for example, be used in conjunction with routing based
2370       on fwmark (needs iproute2). If you plan on doing so, note that the mark
2371       needs  to  be  set  in either the PREROUTING or the OUTPUT chain of the
2372       mangle table to affect routing.  The mark field is 32 bits wide.
2373
2374       --set-xmark value[/mask]
2375              Zeroes out the bits given by mask and XORs value into the packet
2376              mark ("nfmark"). If mask is omitted, 0xFFFFFFFF is assumed.
2377
2378       --set-mark value[/mask]
2379              Zeroes  out the bits given by mask and ORs value into the packet
2380              mark. If mask is omitted, 0xFFFFFFFF is assumed.
2381
2382       The following mnemonics are available:
2383
2384       --and-mark bits
2385              Binary AND the nfmark with bits. (Mnemonic for --set-xmark 0/in‐
2386              vbits, where invbits is the binary negation of bits.)
2387
2388       --or-mark bits
2389              Binary  OR  the  nfmark  with  bits.  (Mnemonic  for --set-xmark
2390              bits/bits.)
2391
2392       --xor-mark bits
2393              Binary XOR the  nfmark  with  bits.  (Mnemonic  for  --set-xmark
2394              bits/0.)
2395
2396   MASQUERADE
2397       This  target  is only valid in the nat table, in the POSTROUTING chain.
2398       It should only be used with dynamically assigned  IP  (dialup)  connec‐
2399       tions: if you have a static IP address, you should use the SNAT target.
2400       Masquerading is equivalent to specifying a mapping to the IP address of
2401       the  interface  the  packet  is going out, but also has the effect that
2402       connections are forgotten when the interface goes down.   This  is  the
2403       correct  behavior when the next dialup is unlikely to have the same in‐
2404       terface address (and hence any established connections  are  lost  any‐
2405       way).
2406
2407       --to-ports port[-port]
2408              This  specifies  a  range of source ports to use, overriding the
2409              default SNAT source port-selection heuristics (see above).  This
2410              is  only  valid  if the rule also specifies one of the following
2411              protocols: tcp, udp, dccp or sctp.
2412
2413       --random
2414              Randomize source port mapping If option --random  is  used  then
2415              port  mapping will be randomized (kernel >= 2.6.21).  Since ker‐
2416              nel 5.0, --random is identical to --random-fully.
2417
2418       --random-fully
2419              Full randomize source port mapping If option  --random-fully  is
2420              used  then  port  mapping  will  be  fully randomized (kernel >=
2421              3.13).
2422
2423       IPv6 support available since Linux kernels >= 3.7.
2424
2425   NETMAP
2426       This target allows you to statically map a whole network  of  addresses
2427       onto  another  network of addresses.  It can only be used from rules in
2428       the nat table.
2429
2430       --to address[/mask]
2431              Network address to map to.  The resulting address will  be  con‐
2432              structed  in  the  following way: All 'one' bits in the mask are
2433              filled in from the new `address'.  All bits that are zero in the
2434              mask are filled in from the original address.
2435
2436       IPv6 support available since Linux kernels >= 3.7.
2437
2438   NFLOG
2439       This  target  provides logging of matching packets. When this target is
2440       set for a rule, the Linux kernel will pass the  packet  to  the  loaded
2441       logging  backend to log the packet. This is usually used in combination
2442       with nfnetlink_log as logging backend, which will multicast the  packet
2443       through  a netlink socket to the specified multicast group. One or more
2444       userspace processes may subscribe to the group to receive the  packets.
2445       Like LOG, this is a non-terminating target, i.e. rule traversal contin‐
2446       ues at the next rule.
2447
2448       --nflog-group nlgroup
2449              The netlink group (0 - 2^16-1) to which packets are (only appli‐
2450              cable for nfnetlink_log). The default value is 0.
2451
2452       --nflog-prefix prefix
2453              A  prefix string to include in the log message, up to 64 charac‐
2454              ters long, useful for distinguishing messages in the logs.
2455
2456       --nflog-range size
2457              This option has never worked, use --nflog-size instead
2458
2459       --nflog-size size
2460              The number of bytes to be copied to userspace  (only  applicable
2461              for  nfnetlink_log).  nfnetlink_log  instances may specify their
2462              own range, this option overrides it.
2463
2464       --nflog-threshold size
2465              Number of packets to queue inside the kernel before sending them
2466              to  userspace (only applicable for nfnetlink_log). Higher values
2467              result in less overhead per packet, but increase delay until the
2468              packets reach userspace. The default value is 1.
2469
2470   NFQUEUE
2471       This  target  passes  the packet to userspace using the nfnetlink_queue
2472       handler.  The packet is put into the queue  identified  by  its  16-bit
2473       queue  number.  Userspace can inspect and modify the packet if desired.
2474       Userspace must then drop  or  reinject  the  packet  into  the  kernel.
2475       Please  see  libnetfilter_queue for details.  nfnetlink_queue was added
2476       in Linux 2.6.14. The queue-balance option was added  in  Linux  2.6.31,
2477       queue-bypass in 2.6.39.
2478
2479       --queue-num value
2480              This  specifies the QUEUE number to use. Valid queue numbers are
2481              0 to 65535. The default value is 0.
2482
2483       --queue-balance value:value
2484              This specifies a range of queues to use. Packets are  then  bal‐
2485              anced  across  the  given  queues.  This is useful for multicore
2486              systems: start multiple instances of the  userspace  program  on
2487              queues  x, x+1, .. x+n and use "--queue-balance x:x+n".  Packets
2488              belonging to the same connection are put into the same nfqueue.
2489
2490       --queue-bypass
2491              By default, if no userspace program is listening on an  NFQUEUE,
2492              then  all  packets that are to be queued are dropped.  When this
2493              option is used, the NFQUEUE rule behaves  like  ACCEPT  instead,
2494              and the packet will move on to the next table.
2495
2496       --queue-cpu-fanout
2497              Available  starting  Linux  kernel 3.10. When used together with
2498              --queue-balance this will use the CPU ID  as  an  index  to  map
2499              packets  to the queues. The idea is that you can improve perfor‐
2500              mance if there's a queue per CPU. This requires  --queue-balance
2501              to be specified.
2502
2503   NOTRACK
2504       This  extension  disables  connection tracking for all packets matching
2505       that rule.  It is equivalent with -j CT --notrack. Like CT, NOTRACK can
2506       only be used in the raw table.
2507
2508   RATEEST
2509       The RATEEST target collects statistics, performs rate estimation calcu‐
2510       lation and saves the results for later  evaluation  using  the  rateest
2511       match.
2512
2513       --rateest-name name
2514              Count  matched  packets into the pool referred to by name, which
2515              is freely choosable.
2516
2517       --rateest-interval amount{s|ms|us}
2518              Rate measurement interval, in seconds, milliseconds or microsec‐
2519              onds.
2520
2521       --rateest-ewmalog value
2522              Rate measurement averaging time constant.
2523
2524   REDIRECT
2525       This  target is only valid in the nat table, in the PREROUTING and OUT‐
2526       PUT chains, and user-defined chains which are only  called  from  those
2527       chains.   It redirects the packet to the machine itself by changing the
2528       destination IP to the primary address of the  incoming  interface  (lo‐
2529       cally-generated  packets are mapped to the localhost address, 127.0.0.1
2530       for IPv4 and ::1 for IPv6, and  packets  arriving  on  interfaces  that
2531       don't have an IP address configured are dropped).
2532
2533       --to-ports port[-port]
2534              This  specifies  a  destination  port  or range of ports to use:
2535              without this, the destination port is never  altered.   This  is
2536              only  valid if the rule also specifies one of the following pro‐
2537              tocols: tcp, udp, dccp or sctp.
2538
2539       --random
2540              If option --random is used then port mapping will be  randomized
2541              (kernel >= 2.6.22).
2542
2543       IPv6 support available starting Linux kernels >= 3.7.
2544
2545   REJECT (IPv6-specific)
2546       This  is  used  to send back an error packet in response to the matched
2547       packet: otherwise it is equivalent to DROP so it is a terminating  TAR‐
2548       GET,  ending  rule  traversal.  This target is only valid in the INPUT,
2549       FORWARD and OUTPUT chains,  and  user-defined  chains  which  are  only
2550       called  from those chains.  The following option controls the nature of
2551       the error packet returned:
2552
2553       --reject-with type
2554              The type given can be icmp6-no-route,  no-route,  icmp6-adm-pro‐
2555              hibited,  adm-prohibited,  icmp6-addr-unreachable, addr-unreach,
2556              or icmp6-port-unreachable, which return the  appropriate  ICMPv6
2557              error  message (icmp6-port-unreachable is the default). Finally,
2558              the option tcp-reset can be used on rules which only  match  the
2559              TCP  protocol:  this  causes  a  TCP RST packet to be sent back.
2560              This is mainly useful for blocking ident (113/tcp) probes  which
2561              frequently  occur  when sending mail to broken mail hosts (which
2562              won't accept your mail otherwise).  tcp-reset can only  be  used
2563              with kernel versions 2.6.14 or later.
2564
2565       Warning:  You  should  not  indiscriminately apply the REJECT target to
2566       packets whose connection state is classified as INVALID;  instead,  you
2567       should only DROP these.
2568
2569       Consider  a source host transmitting a packet P, with P experiencing so
2570       much delay along its path that the source host issues a retransmission,
2571       P_2,  with P_2 being successful in reaching its destination and advanc‐
2572       ing the connection state normally. It is conceivable that the  late-ar‐
2573       riving  P  may  be  considered not to be associated with any connection
2574       tracking entry. Generating a reject response for a  packet  so  classed
2575       would then terminate the healthy connection.
2576
2577       So, instead of:
2578
2579       -A INPUT ... -j REJECT
2580
2581       do consider using:
2582
2583       -A INPUT ... -m conntrack --ctstate INVALID -j DROP -A INPUT ... -j RE‐
2584       JECT
2585
2586   REJECT (IPv4-specific)
2587       This is used to send back an error packet in response  to  the  matched
2588       packet:  otherwise it is equivalent to DROP so it is a terminating TAR‐
2589       GET, ending rule traversal.  This target is only valid  in  the  INPUT,
2590       FORWARD  and  OUTPUT  chains,  and  user-defined  chains which are only
2591       called from those chains.  The following option controls the nature  of
2592       the error packet returned:
2593
2594       --reject-with type
2595              The  type  given can be icmp-net-unreachable, icmp-host-unreach‐
2596              able,       icmp-port-unreachable,       icmp-proto-unreachable,
2597              icmp-net-prohibited, icmp-host-prohibited, or icmp-admin-prohib‐
2598              ited (*),  which  return  the  appropriate  ICMP  error  message
2599              (icmp-port-unreachable  is  the  default).  The option tcp-reset
2600              can be used on rules which only match  the  TCP  protocol:  this
2601              causes  a TCP RST packet to be sent back.  This is mainly useful
2602              for blocking ident (113/tcp) probes which frequently occur  when
2603              sending  mail to broken mail hosts (which won't accept your mail
2604              otherwise).
2605
2606              (*) Using icmp-admin-prohibited with kernels that do not support
2607              it will result in a plain DROP instead of REJECT
2608
2609       Warning:  You  should  not  indiscriminately apply the REJECT target to
2610       packets whose connection state is classified as INVALID;  instead,  you
2611       should only DROP these.
2612
2613       Consider  a source host transmitting a packet P, with P experiencing so
2614       much delay along its path that the source host issues a retransmission,
2615       P_2,  with P_2 being successful in reaching its destination and advanc‐
2616       ing the connection state normally. It is conceivable that the  late-ar‐
2617       riving  P  may  be  considered not to be associated with any connection
2618       tracking entry. Generating a reject response for a  packet  so  classed
2619       would then terminate the healthy connection.
2620
2621       So, instead of:
2622
2623       -A INPUT ... -j REJECT
2624
2625       do consider using:
2626
2627       -A INPUT ... -m conntrack --ctstate INVALID -j DROP -A INPUT ... -j RE‐
2628       JECT
2629
2630   SECMARK
2631       This is used to set the security mark value associated with the  packet
2632       for use by security subsystems such as SELinux.  It is valid in the se‐
2633       curity table (for backwards compatibility with  older  kernels,  it  is
2634       also valid in the mangle table). The mark is 32 bits wide.
2635
2636       --selctx security_context
2637
2638   SET
2639       This  module  adds and/or deletes entries from IP sets which can be de‐
2640       fined by ipset(8).
2641
2642       --add-set setname flag[,flag...]
2643              add the address(es)/port(s) of the packet to the set
2644
2645       --del-set setname flag[,flag...]
2646              delete the address(es)/port(s) of the packet from the set
2647
2648       --map-set setname flag[,flag...]
2649              [--map-mark] [--map-prio] [--map-queue]  map  packet  properties
2650              (firewall mark, tc priority, hardware queue)
2651
2652              where flag(s) are src and/or dst specifications and there can be
2653              no more than six of them.
2654
2655       --timeout value
2656              when adding an entry, the timeout value to use  instead  of  the
2657              default one from the set definition
2658
2659       --exist
2660              when  adding  an  entry  if it already exists, reset the timeout
2661              value to the specified one or to the default from the set  defi‐
2662              nition
2663
2664       --map-set set-name
2665              the  set-name should be created with --skbinfo option --map-mark
2666              map firewall mark to packet  by  lookup  of  value  in  the  set
2667              --map-prio  map  traffic control priority to packet by lookup of
2668              value in the set --map-queue map hardware NIC queue to packet by
2669              lookup of value in the set
2670
2671              The --map-set option can be used from the mangle table only. The
2672              --map-prio and --map-queue flags can be used in the OUTPUT, FOR‐
2673              WARD and POSTROUTING chains.
2674
2675       Use  of  -j  SET requires that ipset kernel support is provided, which,
2676       for standard kernels, is the case since Linux 2.6.39.
2677
2678   SNAT
2679       This target is only valid in the nat table, in the POSTROUTING and  IN‐
2680       PUT  chains,  and  user-defined chains which are only called from those
2681       chains.  It specifies that the source address of the packet  should  be
2682       modified  (and  all future packets in this connection will also be man‐
2683       gled), and rules should cease being examined.  It takes  the  following
2684       options:
2685
2686       --to-source [ipaddr[-ipaddr]][:port[-port]]
2687              which  can  specify a single new source IP address, an inclusive
2688              range of IP addresses. Optionally a port range, if the rule also
2689              specifies  one  of  the  following  protocols: tcp, udp, dccp or
2690              sctp.  If no port range is specified, then  source  ports  below
2691              512  will  be mapped to other ports below 512: those between 512
2692              and 1023 inclusive will be mapped to ports below 1024, and other
2693              ports  will  be mapped to 1024 or above. Where possible, no port
2694              alteration will occur.  In Kernels up to  2.6.10,  you  can  add
2695              several  --to-source  options. For those kernels, if you specify
2696              more than one source address, either via  an  address  range  or
2697              multiple  --to-source  options,  a simple round-robin (one after
2698              another in cycle) takes place between  these  addresses.   Later
2699              Kernels  (>= 2.6.11-rc1) don't have the ability to NAT to multi‐
2700              ple ranges anymore.
2701
2702       --random
2703              If option --random is used then port mapping will be  randomized
2704              through a hash-based algorithm (kernel >= 2.6.21).
2705
2706       --random-fully
2707              If option --random-fully is used then port mapping will be fully
2708              randomized through a PRNG (kernel >= 3.14).
2709
2710       --persistent
2711              Gives a client the  same  source-/destination-address  for  each
2712              connection.   This  supersedes the SAME target. Support for per‐
2713              sistent mappings is available from 2.6.29-rc2.
2714
2715       Kernels prior to 2.6.36-rc1 don't have the ability to SNAT in the INPUT
2716       chain.
2717
2718       IPv6 support available since Linux kernels >= 3.7.
2719
2720   SNPT (IPv6-specific)
2721       Provides  stateless  source IPv6-to-IPv6 Network Prefix Translation (as
2722       described by RFC 6296).
2723
2724       You have to use this target in the mangle table, not in the nat  table.
2725       It takes the following options:
2726
2727       --src-pfx [prefix/length]
2728              Set source prefix that you want to translate and length
2729
2730       --dst-pfx [prefix/length]
2731              Set  destination  prefix that you want to use in the translation
2732              and length
2733
2734       You have to use the DNPT target to undo the translation. Example:
2735
2736              ip6tables -t mangle -I POSTROUTING -s fd00::/64  -o vboxnet0  -j
2737              SNPT --src-pfx fd00::/64 --dst-pfx 2001:e20:2000:40f::/64
2738
2739              ip6tables    -t    mangle    -I    PREROUTING    -i   wlan0   -d
2740              2001:e20:2000:40f::/64 -j DNPT --src-pfx  2001:e20:2000:40f::/64
2741              --dst-pfx fd00::/64
2742
2743       You may need to enable IPv6 neighbor proxy:
2744
2745              sysctl -w net.ipv6.conf.all.proxy_ndp=1
2746
2747       You  also have to use the NOTRACK target to disable connection tracking
2748       for translated flows.
2749
2750   SYNPROXY
2751       This target will process TCP three-way-handshake parallel in  netfilter
2752       context to protect either local or backend system. This target requires
2753       connection tracking because sequence numbers  need  to  be  translated.
2754       The  kernels  ability  to absorb SYNFLOOD was greatly improved starting
2755       with Linux 4.4, so this target should not be needed anymore to  protect
2756       Linux servers.
2757
2758       --mss maximum segment size
2759              Maximum  segment  size announced to clients. This must match the
2760              backend.
2761
2762       --wscale window scale
2763              Window scale announced to clients. This must match the backend.
2764
2765       --sack-perm
2766              Pass client selective acknowledgement option to backend (will be
2767              disabled if not present).
2768
2769       --timestamps
2770              Pass client timestamp option to backend (will be disabled if not
2771              present, also needed for selective  acknowledgement  and  window
2772              scaling).
2773
2774       Example:
2775
2776       Determine tcp options used by backend, from an external system
2777
2778              tcpdump -pni eth0 -c 1 'tcp[tcpflags] == (tcp-syn|tcp-ack)'
2779                  port 80 &
2780              telnet 192.0.2.42 80
2781              18:57:24.693307 IP 192.0.2.42.80 > 192.0.2.43.48757:
2782                  Flags [S.], seq 360414582, ack 788841994, win 14480,
2783                  options [mss 1460,sackOK,
2784                  TS val 1409056151 ecr 9690221,
2785                  nop,wscale 9],
2786                  length 0
2787
2788       Switch  tcp_loose  mode off, so conntrack will mark out-of-flow packets
2789       as state INVALID.
2790
2791              echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose
2792
2793       Make SYN packets untracked
2794
2795              iptables -t raw -A PREROUTING -i eth0 -p tcp --dport 80
2796                  --syn -j CT --notrack
2797
2798       Catch UNTRACKED (SYN packets) and INVALID (3WHS ACK packets) states and
2799       send  them  to  SYNPROXY.  This  rule  will respond to SYN packets with
2800       SYN+ACK syncookies, create ESTABLISHED for valid client response  (3WHS
2801       ACK  packets)  and  drop  incorrect cookies. Flags combinations not ex‐
2802       pected during 3WHS will not match and continue (e.g. SYN+FIN, SYN+ACK).
2803
2804              iptables -A INPUT -i eth0 -p tcp --dport 80
2805                  -m state --state UNTRACKED,INVALID -j SYNPROXY
2806                  --sack-perm --timestamp --mss 1460 --wscale 9
2807
2808       Drop invalid packets, this will be out-of-flow packets  that  were  not
2809       matched by SYNPROXY.
2810
2811              iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state IN‐
2812              VALID -j DROP
2813
2814   TCPMSS
2815       This target alters the MSS value of TCP SYN  packets,  to  control  the
2816       maximum  size for that connection (usually limiting it to your outgoing
2817       interface's MTU minus 40 for IPv4 or 60 for  IPv6,  respectively).   Of
2818       course, it can only be used in conjunction with -p tcp.
2819
2820       This  target  is  used to overcome criminally braindead ISPs or servers
2821       which block "ICMP Fragmentation Needed"  or  "ICMPv6  Packet  Too  Big"
2822       packets.   The  symptoms of this problem are that everything works fine
2823       from your Linux firewall/router, but machines behind it can  never  ex‐
2824       change large packets:
2825
2826       1.  Web browsers connect, then hang with no data received.
2827
2828       2.  Small mail works fine, but large emails hang.
2829
2830       3.  ssh works fine, but scp hangs after initial handshaking.
2831
2832       Workaround:  activate  this option and add a rule to your firewall con‐
2833       figuration like:
2834
2835               iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN
2836                           -j TCPMSS --clamp-mss-to-pmtu
2837
2838       --set-mss value
2839              Explicitly sets MSS option to specified value. If the MSS of the
2840              packet  is  already  lower  than value, it will not be increased
2841              (from Linux 2.6.25 onwards) to avoid more  problems  with  hosts
2842              relying on a proper MSS.
2843
2844       --clamp-mss-to-pmtu
2845              Automatically  clamp  MSS  value to (path_MTU - 40 for IPv4; -60
2846              for IPv6).  This may not function as  desired  where  asymmetric
2847              routes  with differing path MTU exist — the kernel uses the path
2848              MTU which it would use to send packets from itself to the source
2849              and  destination  IP  addresses. Prior to Linux 2.6.25, only the
2850              path MTU to the destination IP address was  considered  by  this
2851              option;  subsequent  kernels  also  consider the path MTU to the
2852              source IP address.
2853
2854       These options are mutually exclusive.
2855
2856   TCPOPTSTRIP
2857       This target will strip TCP options off a TCP packet. (It will  actually
2858       replace  them  by NO-OPs.) As such, you will need to add the -p tcp pa‐
2859       rameters.
2860
2861       --strip-options option[,option...]
2862              Strip the given option(s). The options may be specified  by  TCP
2863              option  number  or  by symbolic name. The list of recognized op‐
2864              tions can be obtained by calling iptables  with  -j  TCPOPTSTRIP
2865              -h.
2866
2867   TEE
2868       The  TEE  target will clone a packet and redirect this clone to another
2869       machine on the local network segment. In other words, the nexthop  must
2870       be  the target, or you will have to configure the nexthop to forward it
2871       further if so desired.
2872
2873       --gateway ipaddr
2874              Send the cloned packet to the host reachable at the given IP ad‐
2875              dress.   Use  of  0.0.0.0 (for IPv4 packets) or :: (IPv6) is in‐
2876              valid.
2877
2878       To forward all incoming traffic on eth0 to  an  Network  Layer  logging
2879       box:
2880
2881       -t mangle -A PREROUTING -i eth0 -j TEE --gateway 2001:db8::1
2882
2883   TOS
2884       This  module sets the Type of Service field in the IPv4 header (includ‐
2885       ing the "precedence" bits) or the Priority field in  the  IPv6  header.
2886       Note  that  TOS shares the same bits as DSCP and ECN. The TOS target is
2887       only valid in the mangle table.
2888
2889       --set-tos value[/mask]
2890              Zeroes out the bits given by mask  (see  NOTE  below)  and  XORs
2891              value  into  the TOS/Priority field. If mask is omitted, 0xFF is
2892              assumed.
2893
2894       --set-tos symbol
2895              You can specify a symbolic name when using the  TOS  target  for
2896              IPv4.  It  implies  a mask of 0xFF (see NOTE below). The list of
2897              recognized TOS names can be obtained by calling iptables with -j
2898              TOS -h.
2899
2900       The following mnemonics are available:
2901
2902       --and-tos bits
2903              Binary  AND  the  TOS  value  with bits. (Mnemonic for --set-tos
2904              0/invbits, where invbits is the binary negation  of  bits.   See
2905              NOTE below.)
2906
2907       --or-tos bits
2908              Binary  OR  the  TOS  value  with  bits. (Mnemonic for --set-tos
2909              bits/bits. See NOTE below.)
2910
2911       --xor-tos bits
2912              Binary XOR the TOS value  with  bits.  (Mnemonic  for  --set-tos
2913              bits/0. See NOTE below.)
2914
2915       NOTE:  In  Linux kernels up to and including 2.6.38, with the exception
2916       of  longterm  releases  2.6.32  (>=.42),  2.6.33  (>=.15),  and  2.6.35
2917       (>=.14),  there  is  a bug whereby IPv6 TOS mangling does not behave as
2918       documented and differs from the IPv4 version. The  TOS  mask  indicates
2919       the  bits  one wants to zero out, so it needs to be inverted before ap‐
2920       plying it to the original TOS field. However, the aformentioned kernels
2921       forgo the inversion which breaks --set-tos and its mnemonics.
2922
2923   TPROXY
2924       This  target is only valid in the mangle table, in the PREROUTING chain
2925       and user-defined chains which are only called from this chain. It redi‐
2926       rects  the  packet to a local socket without changing the packet header
2927       in any way. It can also change the mark value which can then be used in
2928       advanced routing rules.  It takes three options:
2929
2930       --on-port port
2931              This  specifies  a destination port to use. It is a required op‐
2932              tion, 0 means the new destination port is the same as the origi‐
2933              nal.  This is only valid if the rule also specifies -p tcp or -p
2934              udp.
2935
2936       --on-ip address
2937              This specifies a destination address to use. By default the  ad‐
2938              dress  is the IP address of the incoming interface. This is only
2939              valid if the rule also specifies -p tcp or -p udp.
2940
2941       --tproxy-mark value[/mask]
2942              Marks packets with the given value/mask. The  fwmark  value  set
2943              here  can be used by advanced routing. (Required for transparent
2944              proxying to work: otherwise these packets  will  get  forwarded,
2945              which is probably not what you want.)
2946
2947   TRACE
2948       This  target marks packets so that the kernel will log every rule which
2949       match the packets as those traverse the tables, chains, rules.  It  can
2950       only be used in the raw table.
2951
2952       With   iptables-legacy,  a  logging  backend,  such  as  ip(6)t_LOG  or
2953       nfnetlink_log, must be loaded for this to be visible.  The packets  are
2954       logged with the string prefix: "TRACE: tablename:chainname:type:rulenum
2955       " where type can be "rule" for plain rule, "return" for  implicit  rule
2956       at  the  end of a user defined chain and "policy" for the policy of the
2957       built in chains.
2958
2959       With iptables-nft, the target is translated into nftables' meta nftrace
2960       expression.  Hence  the  kernel  sends  trace  events  via  netlink  to
2961       userspace where they may be  displayed  using  xtables-monitor  --trace
2962       command. For details, refer to xtables-monitor(8).
2963
2964   TTL (IPv4-specific)
2965       This is used to modify the IPv4 TTL header field.  The TTL field deter‐
2966       mines how many hops (routers) a packet can traverse until it's time  to
2967       live is exceeded.
2968
2969       Setting  or  incrementing the TTL field can potentially be very danger‐
2970       ous, so it should be avoided at any cost. This target is only valid  in
2971       mangle table.
2972
2973       Don't  ever set or increment the value on packets that leave your local
2974       network!
2975
2976       --ttl-set value
2977              Set the TTL value to `value'.
2978
2979       --ttl-dec value
2980              Decrement the TTL value `value' times.
2981
2982       --ttl-inc value
2983              Increment the TTL value `value' times.
2984
2985   ULOG (IPv4-specific)
2986       This is the deprecated ipv4-only predecessor of the NFLOG  target.   It
2987       provides  userspace  logging  of matching packets.  When this target is
2988       set for a rule, the Linux kernel will multicast this packet  through  a
2989       netlink  socket.  One or more userspace processes may then subscribe to
2990       various multicast groups and receive the packets.  Like LOG, this is  a
2991       "non-terminating  target",  i.e.  rule  traversal continues at the next
2992       rule.
2993
2994       --ulog-nlgroup nlgroup
2995              This specifies the netlink group (1-32) to which the  packet  is
2996              sent.  Default value is 1.
2997
2998       --ulog-prefix prefix
2999              Prefix  log messages with the specified prefix; up to 32 charac‐
3000              ters long, and useful for distinguishing messages in the logs.
3001
3002       --ulog-cprange size
3003              Number of bytes to be copied to userspace.  A value of 0  always
3004              copies the entire packet, regardless of its size.  Default is 0.
3005
3006       --ulog-qthreshold size
3007              Number of packet to queue inside kernel.  Setting this value to,
3008              e.g. 10 accumulates ten packets inside the kernel and  transmits
3009              them  as one netlink multipart message to userspace.  Default is
3010              1 (for backwards compatibility).
3011
3012
3013
3014iptables 1.8.7                                          iptables-extensions(8)
Impressum