Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have fail2ban working properly to block FTP attacks and I want to block "SMTP attacks". I mean I want to block IPs sending mails to non-existent adresses in our mail server. In /var/log/qmail/smtpd/current they are logged as :@400000004a5dced82e4669a4 Reject::RCPT::Failed_Rcptto: P:ESMTP S:187.4.68.30:**** H:**** F:fake-email@fakedomain T:non-existant-email@mydomain
I've configured /etc/fail2ban/filter.d/qmail.conf as follows:
# 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>\S+)
# Values: TEXT
#
#failregex = (?:[\d,.]+[\d,.] rblsmtpd: |421 badiprbl: ip )<HOST>
failregex = Reject::RCPT::Failed_Rcptto: P:ESMTP S:<HOST>
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
Also configured /etc/fail2ban/jail.conf to enable qmail:
You're doing nothing wrong, fail2ban and other 'protection' screens must accept all mail to obey SMTP specs, and then reject, i.e., not queue mail, that meets or does not meet certain conditions. Is there a reason you do not wish to see these?
I believed that fail2ban would block any SMTP connection atempt after the attacking IP was spotted in qmail log and no SMTP dialog would happen afterwards.
We block any email with no valid recipient and/or sender and we donīt send any reply, but I want attacking servers not to connect to our mail server so SMTP connection can't occur.
The point is, if it's an SMTP server, other servers can always connect. What you want is that your server is not relaying messages from users that are not yours, i.e., you want to configure your server so it's not an open relay! Take a look at this for some good info: http://en.wikipedia.org/wiki/Open_mail_relay, and search for securing your mail server.
Frankly, at this stage, if I don't see some activity from people trying to spam through my machine in the logs, I would be worried. It is to be expected. You must be vigilant with your logs!
We already had configured our servers not be an open relay, but I wanted those spammers not even connect to our SMTP servers so we don't have to reject the mail.
I would like to release those "bad" connections inmediately so "legal" senders can connect to our SMTP servers.
Ok, can you post some more info, perhaps a snippet from the logs, an example of a 'bad' connection perhaps? I would like to take a look and compare against my own and some other logs I have on hand.
Same happends to me with a different filter in qmail.
The test run fine, catch a lot of ipaddress but once fail2ban is running don't ban anyting. All I can see in the fail2ban logs is "Log rotation detected for /var/log/qmail/qmail-smtpd/current"
Irishbite, in /var/log/qmail/smtpd/current they are logged as :@400000004a5dced82e4669a4 Reject::RCPT::Failed_Rcptto: P:ESMTP S:187.4.68.30:**** H:**** F:fake-email@fakedomain T:non-existant-email@mydomain
fasuto, thanks for the reply. I think your right, probably fail2ban doesn't ban qmail "attacks" because it doesn't understand qmail log's timestamp.
I'll try to report this issue to fail2ban team so they can fix it. I'll try to find out if there's some way to use "normal" timestamps in qmail logs as well.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.