blob: e91d0c63c8a0babca3a4a430a2ff0a5b655da2eb [file] [log] [blame]
Jan Engelhardtc6775d62010-07-23 21:23:05 +02001\fBhashlimit\fP uses hash buckets to express a rate limiting match (like the
2\fBlimit\fP match) for a group of connections using a \fBsingle\fP iptables
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +01003rule. Grouping can be done per-hostgroup (source and/or destination address)
Jan Engelhardtc6775d62010-07-23 21:23:05 +02004and/or per-port. It gives you the ability to express "\fIN\fP packets per time
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +01005quantum per group":
Jonas Berlinf33c4612005-04-01 06:54:23 +00006.TP
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +01007matching on source host
8"1000 packets per second for every host in 192.168.0.0/16"
Jonas Berlinf33c4612005-04-01 06:54:23 +00009.TP
Jan Engelhardtc5424b92010-06-04 13:05:58 +020010matching on source port
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010011"100 packets per second for every service of 192.168.1.1"
Jonas Berlinf33c4612005-04-01 06:54:23 +000012.TP
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010013matching on subnet
14"10000 packets per minute for every /28 subnet in 10.0.0.0/8"
15.PP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010016A hash limit option (\fB\-\-hashlimit\-upto\fP, \fB\-\-hashlimit\-above\fP) and
17\fB\-\-hashlimit\-name\fP are required.
Jonas Berlinf33c4612005-04-01 06:54:23 +000018.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010019\fB\-\-hashlimit\-upto\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP]
Jan Engelhardtc6775d62010-07-23 21:23:05 +020020Match if the rate is below or equal to \fIamount\fP/quantum. It is specified as
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010021a number, with an optional time quantum suffix; the default is 3/hour.
Jonas Berlinf33c4612005-04-01 06:54:23 +000022.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010023\fB\-\-hashlimit\-above\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP]
Jan Engelhardtc6775d62010-07-23 21:23:05 +020024Match if the rate is above \fIamount\fP/quantum.
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010025.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010026\fB\-\-hashlimit\-burst\fP \fIamount\fP
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010027Maximum initial number of packets to match: this number gets recharged by one
28every time the limit specified above is not reached, up to this number; the
29default is 5.
30.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010031\fB\-\-hashlimit\-mode\fP {\fBsrcip\fP|\fBsrcport\fP|\fBdstip\fP|\fBdstport\fP}\fB,\fP...
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010032A comma-separated list of objects to take into consideration. If no
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010033\-\-hashlimit\-mode option is given, hashlimit acts like limit, but at the
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010034expensive of doing the hash housekeeping.
35.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010036\fB\-\-hashlimit\-srcmask\fP \fIprefix\fP
37When \-\-hashlimit\-mode srcip is used, all source addresses encountered will be
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010038grouped according to the given prefix length and the so-created subnet will be
Jan Engelhardtc6775d62010-07-23 21:23:05 +020039subject to hashlimit. \fIprefix\fP must be between (inclusive) 0 and 32. Note
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010040that \-\-hashlimit\-srcmask 0 is basically doing the same thing as not specifying
41srcip for \-\-hashlimit\-mode, but is technically more expensive.
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010042.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010043\fB\-\-hashlimit\-dstmask\fP \fIprefix\fP
44Like \-\-hashlimit\-srcmask, but for destination addresses.
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010045.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010046\fB\-\-hashlimit\-name\fP \fIfoo\fP
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010047The name for the /proc/net/ipt_hashlimit/foo entry.
48.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010049\fB\-\-hashlimit\-htable\-size\fP \fIbuckets\fP
Jonas Berlinf33c4612005-04-01 06:54:23 +000050The number of buckets of the hash table
51.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010052\fB\-\-hashlimit\-htable\-max\fP \fIentries\fP
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010053Maximum entries in the hash.
Jonas Berlinf33c4612005-04-01 06:54:23 +000054.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010055\fB\-\-hashlimit\-htable\-expire\fP \fImsec\fP
Jan Engelhardt6cf172e2008-03-10 17:48:59 +010056After how many milliseconds do hash entries expire.
Jonas Berlinf33c4612005-04-01 06:54:23 +000057.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010058\fB\-\-hashlimit\-htable\-gcinterval\fP \fImsec\fP
Jan Engelhardt6cf172e2008-03-10 17:48:59 +010059How many milliseconds between garbage collection intervals.