Hi,
Looking through the logs today revealed that my server has been hammered with requests throughout the night for many hours from the same ip-address. This was going on until I added this ip to the miab-postfix587 jail by hand using fail2ban-client.
However I am wondering why fail2ban did not do this automatically since the ip was opening connections every 3 seconds.
This is what mail.log shows:
......
Apr 13 10:21:29 box postfix/submission/smtpd[345606]: connect from unknown[189.190.226.55]
Apr 13 10:21:31 box postfix/submission/smtpd[345606]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:21:31 box postfix/submission/smtpd[345606]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:21:33 box postfix/submission/smtpd[346766]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:21:33 box postfix/submission/smtpd[346766]: connect from unknown[189.190.226.55]
Apr 13 10:21:34 box postfix/submission/smtpd[346766]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:21:34 box postfix/submission/smtpd[346766]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:21:35 box postfix/submission/smtpd[345606]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:21:35 box postfix/submission/smtpd[345606]: connect from unknown[189.190.226.55]
Apr 13 10:21:36 box postfix/submission/smtpd[345606]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:21:36 box postfix/submission/smtpd[345606]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:21:36 box postfix/submission/smtpd[346766]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:21:36 box postfix/submission/smtpd[346766]: connect from unknown[189.190.226.55]
Apr 13 10:21:37 box postfix/submission/smtpd[346766]: disconnect from unknown[189.190.226.55] quit=1 commands=1
Apr 13 10:21:38 box postfix/submission/smtpd[345606]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:21:38 box postfix/submission/smtpd[345606]: connect from unknown[189.190.226.55]
Apr 13 10:21:41 box postfix/submission/smtpd[345606]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:21:41 box postfix/submission/smtpd[345606]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:21:42 box postfix/submission/smtpd[346766]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:21:42 box postfix/submission/smtpd[346766]: connect from unknown[189.190.226.55]
Apr 13 10:22:01 box postfix/submission/smtpd[346766]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:22:01 box postfix/submission/smtpd[346766]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:22:02 box postfix/submission/smtpd[345606]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:22:02 box postfix/submission/smtpd[345606]: connect from unknown[189.190.226.55]
Apr 13 10:22:06 box postfix/submission/smtpd[346766]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:22:06 box postfix/submission/smtpd[346766]: connect from unknown[189.190.226.55]
Apr 13 10:22:07 box postfix/submission/smtpd[345606]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:22:07 box postfix/submission/smtpd[345606]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:22:08 box postfix/submission/smtpd[346766]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:22:08 box postfix/submission/smtpd[346766]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:22:09 box postfix/submission/smtpd[345606]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:22:09 box postfix/submission/smtpd[345606]: connect from unknown[189.190.226.55]
Apr 13 10:22:11 box postfix/submission/smtpd[345606]: lost connection after EHLO from unknown[189.190.226.55]
Apr 13 10:22:11 box postfix/submission/smtpd[345606]: disconnect from unknown[189.190.226.55] ehlo=1 mail=0/1 commands=1/2
Apr 13 10:22:12 box postfix/submission/smtpd[346766]: warning: hostname dsl-189-190-226-55-dyn.prod-infinitum.com.mx does not resolve to address 189.190.226.55: Name or service not known
Apr 13 10:22:12 box postfix/submission/smtpd[346766]: connect from unknown[189.190.226.55]
After I blocked the ip I got this in the logfile:
Apr 13 10:24:28 box postfix/anvil[330116]: statistics: max connection rate 24/60s for (submission:189.190.226.55) at Apr 13 10:15:29
Apr 13 10:24:28 box postfix/anvil[330116]: statistics: max connection count 3 for (submission:189.190.226.55) at Apr 13 10:20:41
Looking through the filter configuration for fail2ban I discovered this in /etc/fail2ban/filter.d/postfix.conf, which should have taken care of the situation.
mdpr-ddos = (?:lost connection after(?! DATA) [A-Z]+|disconnect(?= from \S+(?: \S+=\d+)* auth=0/(?:[1-9]|\d\d+)))
mdre-ddos = ^from [^[]*\[<HOST>\]%(_port)s:?
Further looking into /etc/fail2ban/filter.d/miab-postfix-submission.conf does not show this kind of filter-rule.
So, the question is, if the lines in postfix.conf are even considered or active? Or are those filters some sort of template that need to be referenced by miab-postfix-submission.conf to be actually enabled?
According to /etc/fail2ban/jail.d/mailinabox.conf the ‘maxretry’ value for miab-postfix587 is set to 20. Should this not have triggered the filter as stated in this line?
Apr 13 10:24:28 box postfix/anvil[330116]: statistics: max connection rate 24/60s for
I am not sure I am even looking at the right places right now. Can somebody confirm my thinking or maybe set me on the right track?
Thanks
Lars