<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https:///index.php?action=history&amp;feed=atom&amp;title=Fail2ban</id>
	<title>Fail2ban - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https:///index.php?action=history&amp;feed=atom&amp;title=Fail2ban"/>
	<link rel="alternate" type="text/html" href=""/>
	<updated>2026-04-07T09:25:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id></id>
		<title>Gr0x0rd: /* Installing fail2ban */</title>
		<link rel="alternate" type="text/html" href=""/>
		<updated>2011-05-09T17:02:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Installing fail2ban&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:02, 9 May 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l62&quot; &gt;Line 62:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;logpath = /var/log/messages&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;logpath = /var/log/messages&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;mailcmd = /usr/sbin/sendmail -f  &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;mailcmd = /usr/sbin/sendmail -f  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;mailargs = -c &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;gr0x0rd&lt;/del&gt;@&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;shaw&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ca&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;mailargs = -c &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;youremail&lt;/ins&gt;@&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;host&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ext&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Start the service and add it to startup.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Start the service and add it to startup.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo /etc/init.d/fail2ban start&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo /etc/init.d/fail2ban start&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo rc-update add fail2ban default&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo rc-update add fail2ban default&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gr0x0rd</name></author>
	</entry>
	<entry>
		<id></id>
		<title>Gr0x0rd: Created page with &quot;== Installing fail2ban ==  Fail2ban is a wonderful daemon that monitors your log files and bans IP addresses attacking your server using iptables. Before you begin, check that yo...&quot;</title>
		<link rel="alternate" type="text/html" href=""/>
		<updated>2011-05-09T17:01:15Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Installing fail2ban ==  Fail2ban is a wonderful daemon that monitors your log files and bans IP addresses attacking your server using iptables. Before you begin, check that yo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Installing fail2ban ==&lt;br /&gt;
&lt;br /&gt;
Fail2ban is a wonderful daemon that monitors your log files and bans IP addresses attacking your server using iptables. Before you begin, check that your &amp;#039;&amp;#039;/etc/portage/package.use&amp;#039;&amp;#039; or &amp;#039;&amp;#039;make.conf&amp;#039;&amp;#039; has the &amp;#039;&amp;#039;&amp;#039;threads&amp;#039;&amp;#039;&amp;#039; use flag set for &amp;#039;&amp;#039;dev-lang/python&amp;#039;&amp;#039;. You&amp;#039;ll may need to re-emerge python with the threads use flag if it wasn&amp;#039;t built with it before.&lt;br /&gt;
&lt;br /&gt;
When you are ready, emerge fail2ban.&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo emerge -av fail2ban&lt;br /&gt;
To configure fail2ban, start by creating local config files.&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo nano -w /etc/fail2ban/fail2ban.local&lt;br /&gt;
Add the follwoing line which will recreate the socket if the system crashes or loses power:&lt;br /&gt;
 [Definition]&lt;br /&gt;
 FAIL2BAN_OPTIONS=&amp;quot;-x&amp;quot;&lt;br /&gt;
Save the file. Now create your own jail file:&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo nano -w /etc/fail2ban/jail.local&lt;br /&gt;
Use the following example to configure your jail.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[ssh-iptables]&lt;br /&gt;
&lt;br /&gt;
enabled  = true&lt;br /&gt;
filter   = sshd&lt;br /&gt;
action   = iptables-allports[name=SSH, protocol=all]&lt;br /&gt;
           sendmail-whois[name=SSH, dest=your@email.com, sender=fail2ban@yourserver]&lt;br /&gt;
logpath  = /var/log/messages&lt;br /&gt;
maxretry = 10&lt;br /&gt;
bantime = -1&lt;br /&gt;
&lt;br /&gt;
[pure-ftpd-iptables]&lt;br /&gt;
&lt;br /&gt;
enabled  = true&lt;br /&gt;
filter   = pure-ftpd&lt;br /&gt;
action   = iptables-allports[name=Pure-FTPD, protocol=all]&lt;br /&gt;
           sendmail-whois[name=Pure-FTPD, dest=your@email.com, sender=fail2ban@yourserver]&lt;br /&gt;
logpath  = /var/log/messages&lt;br /&gt;
maxretry = 5&lt;br /&gt;
bantime = -1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Make sure you have set your@email.com and yourserver to the appropriate values. If you want to impose a time limit on the bans, uncomment the bantime fields.&lt;br /&gt;
close and save the file. Now we will set the parameters for pure-ftpd.&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo nano -w /etc/fail2ban/filter.d/pure-ftpd.local&lt;br /&gt;
Use the following example to configure your ftp server sercurity.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Definition]&lt;br /&gt;
failregex = pure-ftpd(?:\[\d+\])?: (.+?@&amp;lt;HOST&amp;gt;\)) \[WARNING\] %(__errmsg)s \[.+\]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to disable notification when the service stops or starts&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo nano -w /etc/fail2ban/action.d/sendmail-whois.local&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Definition]&lt;br /&gt;
&lt;br /&gt;
actionstart = &lt;br /&gt;
actionstop = &lt;br /&gt;
actionban = ADDRESSES=`whois &amp;lt;ip&amp;gt; | perl -e &amp;#039;while (&amp;lt;STDIN&amp;gt;) { next if /^changed|@(ripe|apnic)\.net/io; $m += (/abuse|trouble:|report|spam|security/io?3:0); if (/([a-z0-9_\-\.+]+@[a-z0-9\-]+(\.[[a-z0-9\-]+)+)/io) { while (s/([a-z0-9_\-\.+]+@[a-z0-9\-]+(\.[[a-z0-9\-]+)+)//io) { if ($m) { $a{lc($1)}=$m } else { $b{lc($1)}=$m } } $m=0 } else { $m &amp;amp;&amp;amp; --$m } } if (%%a) {print join(&amp;quot;,&amp;quot;,keys(%%a))} else {print join(&amp;quot;,&amp;quot;,keys(%%b))}&amp;#039;`&lt;br /&gt;
	    IP=&amp;lt;ip&amp;gt;&lt;br /&gt;
            if [ ! -z &amp;quot;$ADDRESSES&amp;quot; ]; then&lt;br /&gt;
                (printf %%b &amp;quot;Subject: [Fail2Ban] &amp;lt;name&amp;gt;: Abuse from &amp;lt;ip&amp;gt;&lt;br /&gt;
		        From: Fail2Ban &amp;lt;&amp;lt;sender&amp;gt;&amp;gt;&lt;br /&gt;
			To: &amp;lt;dest&amp;gt;\n&lt;br /&gt;
			&amp;lt;message&amp;gt;\n&amp;quot;; date &amp;#039;+Note: Local timezone is %%z (%%Z)&amp;#039;; grep &amp;#039;&amp;lt;ip&amp;gt;&amp;#039; &amp;lt;logpath&amp;gt;) | &amp;lt;mailcmd&amp;gt; &amp;lt;sender&amp;gt; $ADDRESSES &amp;lt;mailargs&amp;gt;&lt;br /&gt;
            fi&lt;br /&gt;
&lt;br /&gt;
[Init]&lt;br /&gt;
message = Dear Sir/Madam,\n\nWe have detected abuse from the IP address $IP, which according to a whois lookup is on your network. We would appreciate if you would investigate and take action as appropriate.\n\nLog lines are given below, but please ask if you require any further information.\n\n(If you are not the correct person to contact about this please accept our apologies - your e-mail address was extracted from the whois record by an automated process. This mail was generated by Fail2Ban.)\n&lt;br /&gt;
logpath = /var/log/messages&lt;br /&gt;
mailcmd = /usr/sbin/sendmail -f &lt;br /&gt;
mailargs = -c gr0x0rd@shaw.ca&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Start the service and add it to startup.&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo /etc/init.d/fail2ban start&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$&amp;#039;&amp;#039;&amp;#039; sudo rc-update add fail2ban default&lt;/div&gt;</summary>
		<author><name>Gr0x0rd</name></author>
	</entry>
</feed>