blob: e30bb568ab3084a59d09caa9a9c0e285642814a1 [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.
Jonas Berlinf33c4612005-04-01 06:54:23 +00007.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +02008\fB--name\fR \fIname\fR
9Specify the list to use for the commands. If no name is given then
10\fBDEFAULT\fR will be used.
Jonas Berlinf33c4612005-04-01 06:54:23 +000011.TP
12[\fB!\fR] \fB--set\fR
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020013This will add the source address of the packet to the list. If the source
14address is already in the list, this will update the existing entry. This will
15always return success (or failure if \fB!\fR is passed in).
Jonas Berlinf33c4612005-04-01 06:54:23 +000016.TP
Jan Engelhardtd91bd172008-08-13 14:44:30 +020017\fB--rsource\fP
18Match/save the source address of each packet in the recent list table. This
19is the default.
20.TP
21\fB--rdest\fP
22Match/save the destination address of each packet in the recent list table.
23.TP
Jonas Berlinf33c4612005-04-01 06:54:23 +000024[\fB!\fR] \fB--rcheck\fR
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020025Check if the source address of the packet is currently in the list.
Jonas Berlinf33c4612005-04-01 06:54:23 +000026.TP
27[\fB!\fR] \fB--update\fR
28Like \fB--rcheck\fR, except it will update the "last seen" timestamp if it
29matches.
30.TP
31[\fB!\fR] \fB--remove\fR
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020032Check if the source address of the packet is currently in the list and if so
33that address will be removed from the list and the rule will return true. If
34the address is not found, false is returned.
Jonas Berlinf33c4612005-04-01 06:54:23 +000035.TP
36[\fB!\fR] \fB--seconds \fIseconds\fR
37This option must be used in conjunction with one of \fB--rcheck\fR or
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020038\fB--update\fR. When used, this will narrow the match to only happen when the
39address is in the list and was seen within the last given number of seconds.
Jonas Berlinf33c4612005-04-01 06:54:23 +000040.TP
41[\fB!\fR] \fB--hitcount \fIhits\fR
42This option must be used in conjunction with one of \fB--rcheck\fR or
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020043\fB--update\fR. When used, this will narrow the match to only happen when the
44address is in the list and packets had been received greater than or equal to
45the given value. This option may be used along with \fB--seconds\fR to create
46an even narrower match requiring a certain number of hits within a specific
47time frame.
Jonas Berlinf33c4612005-04-01 06:54:23 +000048.TP
49\fB--rttl\fR
Jan Engelhardta4be7cb2008-09-01 14:28:12 +020050This option may only be used in conjunction with one of \fB--rcheck\fR or
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020051\fB--update\fR. When used, this will narrow the match to only happen when the
52address is in the list and the TTL of the current packet matches that of the
53packet which hit the \fB--set\fR rule. This may be useful if you have problems
54with people faking their source address in order to DoS you via this module by
55disallowing others access to your site by sending bogus packets to you.
56.PP
Jonas Berlinf33c4612005-04-01 06:54:23 +000057Examples:
58.IP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020059iptables -A FORWARD -m recent --name badguy --rcheck --seconds 60 -j DROP
60.IP
61iptables -A FORWARD -p tcp -i eth0 --dport 139 -m recent --name badguy --set -j DROP
62.PP
63Steve's ipt_recent website (http://snowman.net/projects/ipt_recent/) also has
Jonas Berlinf33c4612005-04-01 06:54:23 +000064some examples of usage.
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020065.PP
66\fB/proc/net/xt_recent/*\fR are the current lists of addresses and information
Jonas Berlinf33c4612005-04-01 06:54:23 +000067about each entry of each list.
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020068.PP
69Each file in \fB/proc/net/xt_recent/\fR can be read from to see the current
70list or written two using the following commands to modify the list:
Jonas Berlinf33c4612005-04-01 06:54:23 +000071.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020072\fBecho +\fR\fIaddr\fR\fB >/proc/net/xt_recent/DEFAULT\fR
73to add \fIaddr\fR to the DEFAULT list
Jonas Berlinf33c4612005-04-01 06:54:23 +000074.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020075\fBecho -\fR\fIaddr\fR\fB >/proc/net/xt_recent/DEFAULT\fR
76to remove \fIaddr\fR from the DEFAULT list
Jonas Berlinf33c4612005-04-01 06:54:23 +000077.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020078\fBecho / >/proc/net/xt_recent/DEFAULT\fR
79to flush the DEFAULT list (remove all entries).
80.PP
Jonas Berlinf33c4612005-04-01 06:54:23 +000081The module itself accepts parameters, defaults shown:
82.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020083\fBip_list_tot\fR=\fI100\fR
84Number of addresses remembered per table.
Jonas Berlinf33c4612005-04-01 06:54:23 +000085.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020086\fBip_pkt_list_tot\fR=\fI20\fR
87Number of packets per address remembered.
Jonas Berlinf33c4612005-04-01 06:54:23 +000088.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020089\fBip_list_hash_size\fR=\fI0\fR
90Hash table size. 0 means to calculate it based on ip_list_tot, default: 512.
Jonas Berlinf33c4612005-04-01 06:54:23 +000091.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020092\fBip_list_perms\fR=\fI0644\fR
93Permissions for /proc/net/xt_recent/* files.
Jonas Berlinf33c4612005-04-01 06:54:23 +000094.TP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020095\fBip_list_uid\fR=\fI0\fR
96Numerical UID for ownership of /proc/net/xt_recent/* files.
97.TP
98\fBip_list_gid\fR=\fI0\fR
99Numerical GID for ownership of /proc/net/xt_recent/* files.