Search code examples
regexeximfail2ban

Fail2ban regex for exim


I have tried to write a regex for fail2ban for my exim mail server but I can't seem to get any matches. even on the rejected logfile.

Here is a line from my exim_mainlog:

2014-09-18 16:34:30 dovecot_login authenticator failed for xx-xx-78-xx.dedicated.abac.net (User) [xx.xx.78.xx]:64298: 535 Incorrect authentication data (set_id=sexy)
2014-09-18 16:50:17 dovecot_login authenticator failed for (User) [xx.xx.xx.231]:9859: 535 Incorrect authentication data (set_id=evans)
2014-09-18 16:52:30 dovecot_login authenticator failed for (User) [xx.xx.16.128]:60350: 535 Incorrect authentication data (set_id=orange)
2014-09-18 17:10:19 dovecot_login authenticator failed for XXXX.onlinehome-server.com (User) [xx.xx.96.171]:52799: 535 Incorrect authentication data (set_id=matrix)

the same entries are in my exim_rejectlog.

Here is the filter I tried on both the exim_mainlog and exim_reject log

failregex = \[<HOST>\]: 535 Incorrect authentication data

But I don't get any hits even from the ones that are in the rejectlog

Lines: 257 lines, 0 ignored, 0 matched, 257 missed

Im not very good at regex and would appreciate any help to keep these spammers away


Solution

  • Your server is configured to also log the incoming port, not just the ip address. Change your regex to accommodate the extra characters:

    failregex = \[<HOST>\]:\d+: 535 Incorrect authentication data
    

    Official released version with exim parsing (it now handles the port if it's present). https://github.com/fail2ban/fail2ban/blob/master/config/filter.d/exim.conf