<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Fail2ban on nagg.eu</title><link>https://nagg.eu/tags/fail2ban/</link><description>Recent content in Fail2ban on nagg.eu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 16 Sep 2015 18:54:42 +0000</lastBuildDate><atom:link href="https://nagg.eu/tags/fail2ban/index.xml" rel="self" type="application/rss+xml"/><item><title>ejabberd and fail2ban</title><link>https://nagg.eu/ejabberd-and-fail2ban/</link><pubDate>Wed, 16 Sep 2015 18:54:42 +0000</pubDate><guid>https://nagg.eu/ejabberd-and-fail2ban/</guid><description>&lt;p&gt;Fail2ban is a useful tool capable of mitigating brute force attacks performed
against a multitude of services (ejabberd in our case).&lt;br&gt;
Configuration is split between a multitude of files: &lt;code&gt;jail.conf&lt;/code&gt; defines which
filters are active while the filters scripts are placed in &lt;code&gt;./filter.d&lt;/code&gt; directory.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;[root@CentOS ~]# vi /etc/fail2ban/jail.conf
---
bantime = 1200
findtime = 1200
maxretry = 10

backend = auto

[ejabberd-auth]
enabled = true
port = 5222,5280,7777
action = iptables-multiport[name=ejabberd, port=&amp;#34;5222,5269,5280,777&amp;#34;, protocol=tcp]
logpath = /var/log/ejabberd/ejabberd.log
---
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;[root@CentOS ~]# vi /etc/fail2ban/filter.d/ejabberd-auth.conf
---
[Definition]

failregex = ^=INFO REPORT====  ===\nI\(&amp;lt;0\.\d+\.0&amp;gt;:ejabberd_c2s:\d+\) : \([^)]+\) Failed authentication for .+ from IP &amp;lt;HOST&amp;gt; \({{(?:\d+,){3}\d+},\d+}\)$
                ^(?:\.\d+)? \[info\] &amp;lt;0\.\d+\.\d&amp;gt;@ejabberd_c2s:wait_for_feature_request:\d+ \([^\)]+\) Failed authentication for \S+ from IP &amp;lt;HOST&amp;gt;$
                ^.* Failed authentication for \S+ from &amp;lt;HOST&amp;gt;$
                ^.* from &amp;lt;&amp;lt;&amp;#34;&amp;lt;HOST&amp;gt;&amp;#34;&amp;gt;&amp;gt; failed with error: &amp;lt;&amp;lt;&amp;#34;inexistent-account&amp;#34;&amp;gt;&amp;gt;$
                ^.* from &amp;lt;&amp;lt;&amp;#34;&amp;lt;HOST&amp;gt;&amp;#34;&amp;gt;&amp;gt; failed with error: &amp;lt;&amp;lt;&amp;#34;bad-password&amp;#34;&amp;gt;&amp;gt;$
                ^.* from &amp;lt;&amp;lt;&amp;#34;&amp;lt;HOST&amp;gt;&amp;#34;&amp;gt;&amp;gt; failed with error: &amp;lt;&amp;lt;&amp;#34;badformed-jid&amp;#34;&amp;gt;&amp;gt;$

ignoreregex =

[Init]

journalmatch =
---
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first two regular expressions are for user authentication while the others
are for administration panel login.&lt;br&gt;
Other useful commands are:&lt;/p&gt;</description></item></channel></rss>