• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

Fail2ban for Mailservices

Janko1000

Regular Pleskian
Hi,

i use Fail2ban for several Services. Now i want to protect our Mailservice eg: pop,pops,imap,imaps etc.
My Fail2ban Rule "courierlogin.conf" looks:
Code:
# Fail2Ban configuration file
#
# Author: Christoph Haas
# Modified by: Cyril Jaquier
#
# $Revision: 728 $
#

[Definition]

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values:  TEXT
#
failregex = LOGIN FAILED, ip=\[<HOST>\]$

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
and my jail.conf:
Code:
[courierauth]

enabled  = true
port	 = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter   = courierlogin
logpath  = /opt/psa/var/log/maillog
maxretry = 5
bantime  = 3600

but nothing happend when in /opt/psa/var/log/maillog:
Code:
Nov 18 02:41:00 phi74201 courier-imapd: LOGIN FAILED, user=cust@email.de, ip=[::ffff:123.456.789.000]

- Debian 7
- Plesk 11.5


any hints?
 
1. your failregex is wrong, try this
Code:
failregex = LOGIN FAILED,(.*)ip=\[<HOST>\]$



2. you might want to test your filters with

Code:
fail2ban-regex /path/to/logfile /etc/fail2ban/filter.d/myfilter.conf
 
Last edited:
1. your failregex is wrong, try this
Code:
failregex = LOGIN FAILED,(.*)ip=\[<HOST>\]$



2. you might want to test your filters with

Code:
fail2ban-regex /path/to/logfile /etc/fail2ban/filter.d/myfilter.conf


Thanks a lot :)


Code:
~# fail2ban-regex /opt/psa/var/log/maillog /etc/fail2ban/filter.d/courierlogin.conf
Code:
Success, the total number of match is 133

However, look at the above section 'Running tests' which could contain important
information.

Thanks for the note, but WHEN it is implemented?
 
Last edited:
Back
Top