Fail2ban Disable Stop and Start Emails
Are you fed up with those annoying e-mails that are sent every time the ‘fail2ban’ service is stopped, started or restarted?
You have spent many hours surfing the web looking for a fix that really works, without the need to modify any of the ‘fail2ban’ default configuration files and have still not found one? But, you would like to continue to receive e-mails on ban action/s.
If so, here is what I did to achieve this.
Tones: # cd /etc/fail2ban/action.d Tones: # vi stop-start.local Enter the following three lines and then write the file away. [Definition] actionstart = actionstop =
Whether you are using sendmail or mail as the mta I will be covering both below. We are now going to list all mail conf and sendmail conf into a file to make the job easy. But you could manually carry out the below line by line if you wish. First ensure that you are still in the action.d directory.
Tones: # cd /etc/fail2ban/action.d Tones: # ls mail* >doit Tones: # ls sendmail* >>doit Your 'doit' file will look something like this. mail-buffered.conf mail-whois-common.conf mail-whois-lines.conf mail-whois.conf mail.conf sendmail-buffered.conf sendmail-common.conf sendmail-geoip-lines.conf sendmail-whois-ipjailmatches.conf sendmail-whois-ipmatches.conf sendmail-whois-lines.conf sendmail-whois-matches.conf sendmail-whois.conf sendmail.conf
Now edit the ‘doit’ file to change all of the .conf to be .local
Then at the beginning of each line enter the following so your file looks like the below:
ln -s stop-start.local mail-buffered.local ln -s stop-start.local mail-whois-common.local ln -s stop-start.local mail-whois-lines.local ln -s stop-start.local mail-whois.local ln -s stop-start.local mail.local ln -s stop-start.local sendmail-buffered.local ln -s stop-start.local sendmail-common.local ln -s stop-start.local sendmail-geoip-lines.local ln -s stop-start.local sendmail-whois-ipjailmatches.local ln -s stop-start.local sendmail-whois-ipmatches.local ln -s stop-start.local sendmail-whois-lines.local ln -s stop-start.local sendmail-whois-matches.local ln -s stop-start.local sendmail-whois.local ln -s stop-start.local sendmail.local Now change the file to be executable and then run it. Tones: # chmod 755 ./doit Tones: # ./doit
You will now have linked .local files which will override and disable any actionstart or actionstop contained in them to prevent the annoying service stop/start e-mails.
Now all there is to do is to restart ‘fail2ban’ to read the new changes.
Tones: # service fail2ban restart
Hope this has been useful.
Tone.
Has one comment to “Fail2ban Disable Stop and Start Emails”
mcb - 30/11/2019
Thank you !!!!! at last a solution that worked (30 nov 2019) : no more start / stop notifications and ban notifications still implemented. Great !