I have fail2ban configured on some CentOS 5 and 6 servers, and it sends me an email with a whois of the IP whenever an IP is banned. Is it possible to configure fail2ban to also send a notification to the email from the whois report?
Here is my jail config:
# /etc/fail2ban/jail.conf
[ssh-iptables]
enabled = true
filter = sshd
action = iptables-allports[name=SSH, protocol=all]
sendmail-whois[name=SSH, [email protected], sender=fail2ban]
logpath = /var/log/secure
maxretry = 3
Is there some sort of variable I can put it dest=
to send to the whois email?
Looks like there is an action the comes with fail2ban called
complain
. Notice the line withcomplain[logpath=/var/log/secure]
:Add that line and restart the fail2ban service. The action conf file is /etc/fail2ban/action.d/complain.conf. Short description:
It's possible. (Depending on how strictly you define "have fail2ban do this.") Doesn't strike me as a particularly fruitful waste of time, though.
Basically, you'd take your
whois
to get the domain owner, and send an email to abuse@[domain].[tld] to let them know that someone on one of their hosts is trying to gain unauthorized access to your system, and attach the logs, presumably. (You could also send one to the email in the whois, as you suggest, but that's even less likely to reach anyone who cares or can do something about it.) You'd have to hope that:abuse
is the right address (you could try other ones, but that would be the most common by far) and is monitored. (Same of the email address listed in the whois - if it's not valid or not monitored, you're wastign your time right off the bat.)Any one of those conditions being false guarantee that you're completely wasting your time, and in my experience, 2, 4, 5, and 6 are almost always false, so what you're looking to so is a complete waste of time, unless you're looking to use this as a learning experience to become a better scripter.
To add to the answer by @Banjer (which is correct): you don't really need both actions "sendmail-whois" and "complain" if you configure the action "complain" correctly:
And:
That way, the internet service provider administering the offending IP address will be contacted automatically AND you will receive a copy of the e-mail in cc: ('-c'-option to the mailargs variable).
I have also added the WHOIS-information to the message-variable, which is not a default in the Debian-configuration, but is a nice addon to the default message imho.