I can see in my error log of apache an IP trying regularly accessed to a non existing file. Fail2ban doesn't ban this ip automatically because the frequency of request is too slow.
1) So how can I add manually this ip to non-permanent ban list of fail2ban? Maybe there is an other tools/method too ban IP during X hours (with X parameterized)?
2) Where can I watch the complete list of IP actually ban by fail2ban?
thx.
I'd recommend that you use the
apache-nohome
filter, which I believe should be included in yourfilter.d
directory by default - if not, please create the fileapache-nohome.conf
in yourfilter.d
subdirectory containing the following:You can then amend this by creating an
apache-nohome.local
in the same directory if you should need to amend the regex at all, which will override the.conf
version (as per the fail2ban documentation).Once you have created this file, you will need to include an appropriate corresponding segment in your jail configuration - if you have not already done so, copy your jail.conf file to jail.local for editing, and insert a segment similar to the following, as an example:
To briefly explain the above jail - this will ban all IP traffic for hosts matching the fail regex in the apache-nohome filter, after 5 instances in a 24 hour period, and ban said IP for one month. It then sends you an email with the WHOIS details of the offending IP. You can of course amend the
maxretry
value or thefindtime
orbantime
values to anything you wish, and even remove thesendmail-whois
line from the action if you prefer not to receive an email on each ban. You may also wish to amend the logpath value to be appropriate for whichever logs you wish to scan - I have merely provided the default error logs path for httpd under CentOS 6.5 as an example.Hope this helps!