Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 1 | \fBhashlimit\fR uses hash buckets to express a rate limiting match (like the |
| 2 | \fBlimit\fR match) for a group of connections using a \fBsingle\fR iptables |
| 3 | rule. Grouping can be done per-hostgroup (source and/or destination address) |
| 4 | and/or per-port. It gives you the ability to express "\fIN\fR packets per time |
| 5 | quantum per group": |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 6 | .TP |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 7 | matching on source host |
| 8 | "1000 packets per second for every host in 192.168.0.0/16" |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 9 | .TP |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 10 | matching on source prot |
| 11 | "100 packets per second for every service of 192.168.1.1" |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 12 | .TP |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 13 | matching on subnet |
| 14 | "10000 packets per minute for every /28 subnet in 10.0.0.0/8" |
| 15 | .PP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 16 | A hash limit option (\fB\-\-hashlimit\-upto\fP, \fB\-\-hashlimit\-above\fP) and |
| 17 | \fB\-\-hashlimit\-name\fP are required. |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 18 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 19 | \fB\-\-hashlimit\-upto\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP] |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 20 | Match if the rate is below or equal to \fIamount\fR/quantum. It is specified as |
| 21 | a number, with an optional time quantum suffix; the default is 3/hour. |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 22 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 23 | \fB\-\-hashlimit\-above\fP \fIamount\fP[\fB/second\fP|\fB/minute\fP|\fB/hour\fP|\fB/day\fP] |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 24 | Match if the rate is above \fIamount\fR/quantum. |
| 25 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 26 | \fB\-\-hashlimit\-burst\fP \fIamount\fP |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 27 | Maximum initial number of packets to match: this number gets recharged by one |
| 28 | every time the limit specified above is not reached, up to this number; the |
| 29 | default is 5. |
| 30 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 31 | \fB\-\-hashlimit\-mode\fP {\fBsrcip\fP|\fBsrcport\fP|\fBdstip\fP|\fBdstport\fP}\fB,\fP... |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 32 | A comma-separated list of objects to take into consideration. If no |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 33 | \-\-hashlimit\-mode option is given, hashlimit acts like limit, but at the |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 34 | expensive of doing the hash housekeeping. |
| 35 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 36 | \fB\-\-hashlimit\-srcmask\fP \fIprefix\fP |
| 37 | When \-\-hashlimit\-mode srcip is used, all source addresses encountered will be |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 38 | grouped according to the given prefix length and the so-created subnet will be |
| 39 | subject to hashlimit. \fIprefix\fR must be between (inclusive) 0 and 32. Note |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 40 | that \-\-hashlimit\-srcmask 0 is basically doing the same thing as not specifying |
| 41 | srcip for \-\-hashlimit\-mode, but is technically more expensive. |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 42 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 43 | \fB\-\-hashlimit\-dstmask\fP \fIprefix\fP |
| 44 | Like \-\-hashlimit\-srcmask, but for destination addresses. |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 45 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 46 | \fB\-\-hashlimit\-name\fP \fIfoo\fP |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 47 | The name for the /proc/net/ipt_hashlimit/foo entry. |
| 48 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 49 | \fB\-\-hashlimit\-htable\-size\fP \fIbuckets\fP |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 50 | The number of buckets of the hash table |
| 51 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 52 | \fB\-\-hashlimit\-htable\-max\fP \fIentries\fP |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 53 | Maximum entries in the hash. |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 54 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 55 | \fB\-\-hashlimit\-htable\-expire\fP \fImsec\fP |
Jan Engelhardt | 6cf172e | 2008-03-10 17:48:59 +0100 | [diff] [blame] | 56 | After how many milliseconds do hash entries expire. |
Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 57 | .TP |
Jan Engelhardt | fea74bf | 2009-01-12 04:53:18 +0100 | [diff] [blame] | 58 | \fB\-\-hashlimit\-htable\-gcinterval\fP \fImsec\fP |
Jan Engelhardt | 6cf172e | 2008-03-10 17:48:59 +0100 | [diff] [blame] | 59 | How many milliseconds between garbage collection intervals. |