| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 1 | Allows you to dynamically create a list of IP addresses and then match against |
| 2 | that list in a few different ways. |
| 3 | .PP |
| 4 | For example, you can create a "badguy" list out of people attempting to connect |
| 5 | to port 139 on your firewall and then DROP all future packets from them without |
| 6 | considering them. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 7 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 8 | \fB--name\fR \fIname\fR |
| 9 | Specify the list to use for the commands. If no name is given then |
| 10 | \fBDEFAULT\fR will be used. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 11 | .TP |
| 12 | [\fB!\fR] \fB--set\fR |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 13 | This will add the source address of the packet to the list. If the source |
| 14 | address is already in the list, this will update the existing entry. This will |
| 15 | always return success (or failure if \fB!\fR is passed in). |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 16 | .TP |
| Jan Engelhardt | d91bd17 | 2008-08-13 14:44:30 +0200 | [diff] [blame] | 17 | \fB--rsource\fP |
| 18 | Match/save the source address of each packet in the recent list table. This |
| 19 | is the default. |
| 20 | .TP |
| 21 | \fB--rdest\fP |
| 22 | Match/save the destination address of each packet in the recent list table. |
| 23 | .TP |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 24 | [\fB!\fR] \fB--rcheck\fR |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 25 | Check if the source address of the packet is currently in the list. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 26 | .TP |
| 27 | [\fB!\fR] \fB--update\fR |
| 28 | Like \fB--rcheck\fR, except it will update the "last seen" timestamp if it |
| 29 | matches. |
| 30 | .TP |
| 31 | [\fB!\fR] \fB--remove\fR |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 32 | Check if the source address of the packet is currently in the list and if so |
| 33 | that address will be removed from the list and the rule will return true. If |
| 34 | the address is not found, false is returned. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 35 | .TP |
| 36 | [\fB!\fR] \fB--seconds \fIseconds\fR |
| 37 | This option must be used in conjunction with one of \fB--rcheck\fR or |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 38 | \fB--update\fR. When used, this will narrow the match to only happen when the |
| 39 | address is in the list and was seen within the last given number of seconds. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 40 | .TP |
| 41 | [\fB!\fR] \fB--hitcount \fIhits\fR |
| 42 | This option must be used in conjunction with one of \fB--rcheck\fR or |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 43 | \fB--update\fR. When used, this will narrow the match to only happen when the |
| 44 | address is in the list and packets had been received greater than or equal to |
| 45 | the given value. This option may be used along with \fB--seconds\fR to create |
| 46 | an even narrower match requiring a certain number of hits within a specific |
| 47 | time frame. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 48 | .TP |
| 49 | \fB--rttl\fR |
| Jan Engelhardt | a4be7cb | 2008-09-01 14:28:12 +0200 | [diff] [blame] | 50 | This option may only be used in conjunction with one of \fB--rcheck\fR or |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 51 | \fB--update\fR. When used, this will narrow the match to only happen when the |
| 52 | address is in the list and the TTL of the current packet matches that of the |
| 53 | packet which hit the \fB--set\fR rule. This may be useful if you have problems |
| 54 | with people faking their source address in order to DoS you via this module by |
| 55 | disallowing others access to your site by sending bogus packets to you. |
| 56 | .PP |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 57 | Examples: |
| 58 | .IP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 59 | iptables -A FORWARD -m recent --name badguy --rcheck --seconds 60 -j DROP |
| 60 | .IP |
| 61 | iptables -A FORWARD -p tcp -i eth0 --dport 139 -m recent --name badguy --set -j DROP |
| 62 | .PP |
| 63 | Steve's ipt_recent website (http://snowman.net/projects/ipt_recent/) also has |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 64 | some examples of usage. |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 65 | .PP |
| 66 | \fB/proc/net/xt_recent/*\fR are the current lists of addresses and information |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 67 | about each entry of each list. |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 68 | .PP |
| 69 | Each file in \fB/proc/net/xt_recent/\fR can be read from to see the current |
| 70 | list or written two using the following commands to modify the list: |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 71 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 72 | \fBecho +\fR\fIaddr\fR\fB >/proc/net/xt_recent/DEFAULT\fR |
| 73 | to add \fIaddr\fR to the DEFAULT list |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 74 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 75 | \fBecho -\fR\fIaddr\fR\fB >/proc/net/xt_recent/DEFAULT\fR |
| 76 | to remove \fIaddr\fR from the DEFAULT list |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 77 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 78 | \fBecho / >/proc/net/xt_recent/DEFAULT\fR |
| 79 | to flush the DEFAULT list (remove all entries). |
| 80 | .PP |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 81 | The module itself accepts parameters, defaults shown: |
| 82 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 83 | \fBip_list_tot\fR=\fI100\fR |
| 84 | Number of addresses remembered per table. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 85 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 86 | \fBip_pkt_list_tot\fR=\fI20\fR |
| 87 | Number of packets per address remembered. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 88 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 89 | \fBip_list_hash_size\fR=\fI0\fR |
| 90 | Hash table size. 0 means to calculate it based on ip_list_tot, default: 512. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 91 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 92 | \fBip_list_perms\fR=\fI0644\fR |
| 93 | Permissions for /proc/net/xt_recent/* files. |
| Jonas Berlin | f33c461 | 2005-04-01 06:54:23 +0000 | [diff] [blame] | 94 | .TP |
| Jan Engelhardt | c7f0e94 | 2008-10-22 18:53:57 +0200 | [diff] [blame^] | 95 | \fBip_list_uid\fR=\fI0\fR |
| 96 | Numerical UID for ownership of /proc/net/xt_recent/* files. |
| 97 | .TP |
| 98 | \fBip_list_gid\fR=\fI0\fR |
| 99 | Numerical GID for ownership of /proc/net/xt_recent/* files. |