blob: e03d8ece58fc8344ec407ef69985184f51aef157 [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 Engelhardtfea74bf2009-01-12 04:53:18 +01008\fB\-\-name\fP \fIname\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +02009Specify 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
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010012[\fB!\fR] \fB\-\-set\fP
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 Engelhardtfea74bf2009-01-12 04:53:18 +010017\fB\-\-rsource\fP
Jan Engelhardtd91bd172008-08-13 14:44:30 +020018Match/save the source address of each packet in the recent list table. This
19is the default.
20.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010021\fB\-\-rdest\fP
Jan Engelhardtd91bd172008-08-13 14:44:30 +020022Match/save the destination address of each packet in the recent list table.
23.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010024[\fB!\fR] \fB\-\-rcheck\fP
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
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010027[\fB!\fR] \fB\-\-update\fP
28Like \fB\-\-rcheck\fP, except it will update the "last seen" timestamp if it
Jonas Berlinf33c4612005-04-01 06:54:23 +000029matches.
30.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010031[\fB!\fR] \fB\-\-remove\fP
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
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010036[\fB!\fR] \fB\-\-seconds \fIseconds\fP
37This option must be used in conjunction with one of \fB\-\-rcheck\fP or
38\fB\-\-update\fP. When used, this will narrow the match to only happen when the
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020039address is in the list and was seen within the last given number of seconds.
Jonas Berlinf33c4612005-04-01 06:54:23 +000040.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010041[\fB!\fR] \fB\-\-hitcount \fIhits\fP
42This option must be used in conjunction with one of \fB\-\-rcheck\fP or
43\fB\-\-update\fP. When used, this will narrow the match to only happen when the
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020044address is in the list and packets had been received greater than or equal to
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010045the given value. This option may be used along with \fB\-\-seconds\fP to create
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020046an even narrower match requiring a certain number of hits within a specific
47time frame.
Jonas Berlinf33c4612005-04-01 06:54:23 +000048.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010049\fB\-\-rttl\fP
50This option may only be used in conjunction with one of \fB\-\-rcheck\fP or
51\fB\-\-update\fP. When used, this will narrow the match to only happen when the
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020052address is in the list and the TTL of the current packet matches that of the
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010053packet which hit the \fB\-\-set\fP rule. This may be useful if you have problems
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020054with 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 Engelhardtfea74bf2009-01-12 04:53:18 +010059iptables \-A FORWARD \-m recent \-\-name badguy \-\-rcheck \-\-seconds 60 \-j DROP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020060.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010061iptables \-A FORWARD \-p tcp \-i eth0 \-\-dport 139 \-m recent \-\-name badguy \-\-set \-j DROP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020062.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 Engelhardtfea74bf2009-01-12 04:53:18 +010075\fBecho \-\fP\fIaddr\fP\fB >/proc/net/xt_recent/DEFAULT\fP
Jan Engelhardtc7f0e942008-10-22 18:53:57 +020076to 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.