blob: 0392c2cac9c011cb4af58bb5441b6062f900a09e [file] [log] [blame]
Jan Engelhardtc7f0e942008-10-22 18:53:57 +02001Allows you to dynamically create a list of IP addresses and then match against
2that list in a few different ways.
3.PP
4For example, you can create a "badguy" list out of people attempting to connect
5to port 139 on your firewall and then DROP all future packets from them without
6considering them.
Jan Engelhardt27c8d2a2010-01-19 18:15:19 +01007.PP
8\fB\-\-set\fP, \fB\-\-rcheck\fP, \fB\-\-update\fP and \fB\-\-remove\fP are
9mutually exclusive.
Jonas Berlinf33c4612005-04-01 06:54:23 +000010.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010011\fB\-\-name\fP \fIname\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020012Specify the list to use for the commands. If no name is given then
Jan Engelhardtc6775d62010-07-23 21:23:05 +020013\fBDEFAULT\fP will be used.
Jonas Berlinf33c4612005-04-01 06:54:23 +000014.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020015[\fB!\fP] \fB\-\-set\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020016This will add the source address of the packet to the list. If the source
17address is already in the list, this will update the existing entry. This will
Jan Engelhardtc6775d62010-07-23 21:23:05 +020018always return success (or failure if \fB!\fP is passed in).
Jonas Berlinf33c4612005-04-01 06:54:23 +000019.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010020\fB\-\-rsource\fP
Jan Engelhardtd91bd172008-08-13 14:44:30 +020021Match/save the source address of each packet in the recent list table. This
22is the default.
23.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010024\fB\-\-rdest\fP
Jan Engelhardtd91bd172008-08-13 14:44:30 +020025Match/save the destination address of each packet in the recent list table.
26.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020027[\fB!\fP] \fB\-\-rcheck\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020028Check if the source address of the packet is currently in the list.
Jonas Berlinf33c4612005-04-01 06:54:23 +000029.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020030[\fB!\fP] \fB\-\-update\fP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010031Like \fB\-\-rcheck\fP, except it will update the "last seen" timestamp if it
Jonas Berlinf33c4612005-04-01 06:54:23 +000032matches.
33.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020034[\fB!\fP] \fB\-\-remove\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020035Check if the source address of the packet is currently in the list and if so
36that address will be removed from the list and the rule will return true. If
37the address is not found, false is returned.
Jonas Berlinf33c4612005-04-01 06:54:23 +000038.TP
Jan Engelhardt27c8d2a2010-01-19 18:15:19 +010039\fB\-\-seconds\fP \fIseconds\fP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010040This option must be used in conjunction with one of \fB\-\-rcheck\fP or
41\fB\-\-update\fP. When used, this will narrow the match to only happen when the
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020042address is in the list and was seen within the last given number of seconds.
Jonas Berlinf33c4612005-04-01 06:54:23 +000043.TP
Jan Engelhardt27c8d2a2010-01-19 18:15:19 +010044\fB\-\-hitcount\fP \fIhits\fP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010045This option must be used in conjunction with one of \fB\-\-rcheck\fP or
46\fB\-\-update\fP. When used, this will narrow the match to only happen when the
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020047address is in the list and packets had been received greater than or equal to
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010048the given value. This option may be used along with \fB\-\-seconds\fP to create
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020049an even narrower match requiring a certain number of hits within a specific
Jan Engelhardt75736312009-11-17 23:54:29 +010050time frame. The maximum value for the hitcount parameter is given by the
51"ip_pkt_list_tot" parameter of the xt_recent kernel module. Exceeding this
52value on the command line will cause the rule to be rejected.
Jonas Berlinf33c4612005-04-01 06:54:23 +000053.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010054\fB\-\-rttl\fP
55This option may only be used in conjunction with one of \fB\-\-rcheck\fP or
56\fB\-\-update\fP. When used, this will narrow the match to only happen when the
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020057address is in the list and the TTL of the current packet matches that of the
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010058packet which hit the \fB\-\-set\fP rule. This may be useful if you have problems
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020059with people faking their source address in order to DoS you via this module by
60disallowing others access to your site by sending bogus packets to you.
61.PP
Jonas Berlinf33c4612005-04-01 06:54:23 +000062Examples:
63.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010064iptables \-A FORWARD \-m recent \-\-name badguy \-\-rcheck \-\-seconds 60 \-j DROP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020065.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010066iptables \-A FORWARD \-p tcp \-i eth0 \-\-dport 139 \-m recent \-\-name badguy \-\-set \-j DROP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020067.PP
68Steve's ipt_recent website (http://snowman.net/projects/ipt_recent/) also has
Jonas Berlinf33c4612005-04-01 06:54:23 +000069some examples of usage.
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020070.PP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020071\fB/proc/net/xt_recent/*\fP are the current lists of addresses and information
Jonas Berlinf33c4612005-04-01 06:54:23 +000072about each entry of each list.
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020073.PP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020074Each file in \fB/proc/net/xt_recent/\fP can be read from to see the current
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020075list or written two using the following commands to modify the list:
Jonas Berlinf33c4612005-04-01 06:54:23 +000076.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020077\fBecho +\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP
78to add \fIaddr\fP to the DEFAULT list
Jonas Berlinf33c4612005-04-01 06:54:23 +000079.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010080\fBecho \-\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020081to remove \fIaddr\fP from the DEFAULT list
Jonas Berlinf33c4612005-04-01 06:54:23 +000082.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020083\fBecho / >/proc/net/xt_recent/DEFAULT\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020084to flush the DEFAULT list (remove all entries).
85.PP
Jonas Berlinf33c4612005-04-01 06:54:23 +000086The module itself accepts parameters, defaults shown:
87.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020088\fBip_list_tot\fP=\fI100\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020089Number of addresses remembered per table.
Jonas Berlinf33c4612005-04-01 06:54:23 +000090.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020091\fBip_pkt_list_tot\fP=\fI20\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020092Number of packets per address remembered.
Jonas Berlinf33c4612005-04-01 06:54:23 +000093.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020094\fBip_list_hash_size\fP=\fI0\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020095Hash table size. 0 means to calculate it based on ip_list_tot, default: 512.
Jonas Berlinf33c4612005-04-01 06:54:23 +000096.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020097\fBip_list_perms\fP=\fI0644\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020098Permissions for /proc/net/xt_recent/* files.
Jonas Berlinf33c4612005-04-01 06:54:23 +000099.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +0200100\fBip_list_uid\fP=\fI0\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +0200101Numerical UID for ownership of /proc/net/xt_recent/* files.
102.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +0200103\fBip_list_gid\fP=\fI0\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +0200104Numerical GID for ownership of /proc/net/xt_recent/* files.