I have set up fail2ban for Postfix, banning failed attempts after 10 tries.
It "works" in the sense that the ban does get triggered.
I even get an email about it, so
the mail-whois action works.
But it seems the IP address is never banned in iptables, meaning the
iptables action doesn't seem to be working. Any ideas?
This is my /etc/fail2ban/jail.local file:
Code:
[postfix]
enabled = true
port = smtp,ssmtp
filter = postfix
action = mail-whois[name=postfix, dest=my@email.com]
iptables[name=postfix, port=smtp, protocol=tcp]
iptables[name=postfix, port=ssmtp, protocol=tcp]
logpath = /var/log/mail.log
maxretry = 10
This is my /etc/fail2ban/filter.d/postfix.local:
Code:
[Definition]
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed
reject: RCPT from (.*)\[<HOST>\]: 554
ignoreregex =
This is how the /var/log/mail.log file looks. (I have changed the IP address etc. for privacy reasons, and changed "authentication failure" to "auth. failure" to make it more readable).
Notice how fail2ban sends the email after 10 (or rather 11) failed attempts. But the guy can still connect to my server after that. He continues to do so until time 06:55:56, a whole minute after the "ban".Why? Maybe it takes iptables that long to apply the ban?
Code:
Oct 26 06:54:42 plato postfix/smtpd[15226]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:43 plato postfix/smtpd[15231]: connect from unknown[12.345.678.912]
Oct 26 06:54:44 plato postfix/smtpd[15231]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:44 plato postfix/smtpd[15232]: connect from unknown[12.345.678.912]
Oct 26 06:54:45 plato postfix/smtpd[15232]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:46 plato postfix/smtpd[15233]: connect from unknown[12.345.678.912]
Oct 26 06:54:47 plato postfix/smtpd[15233]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:47 plato postfix/smtpd[15234]: connect from unknown[12.345.678.912]
Oct 26 06:54:48 plato postfix/smtpd[15234]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:49 plato postfix/smtpd[15235]: connect from unknown[12.345.678.912]
Oct 26 06:54:50 plato postfix/smtpd[15235]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:50 plato postfix/smtpd[15236]: connect from unknown[12.345.678.912]
Oct 26 06:54:51 plato postfix/smtpd[15236]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:52 plato postfix/smtpd[15237]: connect from unknown[12.345.678.912]
Oct 26 06:54:53 plato postfix/smtpd[15237]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:53 plato postfix/smtpd[15238]: connect from unknown[12.345.678.912]
Oct 26 06:54:54 plato postfix/smtpd[15238]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:55 plato postfix/smtpd[15239]: connect from unknown[12.345.678.912]
Oct 26 06:54:56 plato postfix/smtpd[15239]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:56 plato postfix/smtpd[15240]: connect from unknown[12.345.678.912]
Oct 26 06:54:57 plato postfix/smtpd[15240]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:57 plato postfix/pickup[15215]: E57BF33B49: uid=0 from=<root>
Oct 26 06:54:57 plato postfix/cleanup[15248]: E57BF33B49: message-id=<20131026999999.E57BF33B49@plato.email.com>
Oct 26 06:54:57 plato postfix/qmgr[9270]: E57BF33B49: from=<root@plato.email.com>, size=2023, nrcpt=1 (queue active)
Oct 26 06:54:57 plato postfix/pipe[15254]: E57BF33B49: to=<my@email.com>, relay=dovecot, delay=0.02, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (delivered via dovecot service)
Oct 26 06:54:57 plato postfix/qmgr[9270]: E57BF33B49: removed
Oct 26 06:54:58 plato postfix/smtpd[15258]: connect from unknown[12.345.678.912]
Oct 26 06:54:59 plato postfix/smtpd[15258]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:54:59 plato postfix/smtpd[15259]: connect from unknown[12.345.678.912]
Oct 26 06:55:00 plato postfix/smtpd[15259]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:55:01 plato postfix/smtpd[15260]: connect from unknown[12.345.678.912]
Oct 26 06:55:02 plato postfix/smtpd[15260]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:55:02 plato postfix/smtpd[15261]: connect from unknown[12.345.678.912]
Oct 26 06:55:03 plato postfix/smtpd[15261]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:55:04 plato postfix/smtpd[15262]: connect from unknown[12.345.678.912]
Oct 26 06:55:05 plato postfix/smtpd[15262]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 26 06:55:05 plato postfix/smtpd[15263]: connect from unknown[12.345.678.912]
...
Oct 27 06:55:56 plato postfix/smtpd[15296]: warning: unknown[12.345.678.912]: SASL LOGIN authentication failed: auth. failure
Oct 27 06:55:56 plato postfix/smtpd[15297]: connect from unknown[12.345.678.912]
Oct 27 06:55:56 plato postfix/smtpd[15297]: warning: Connection concurrency limit exceeded: 51 from unknown[12.345.678.912] for service smtp