I have this fail2ban jail targeting an apache log (currently with some small values so I can experiment):
enabled = true
maxretry = 3
bantime = 10
findtime = 5
action = 429-ban
I stress test it using ab
(with concurrency: 10, requests: 10000) and my custom filter catches the "high" traffic almost immediately and bans the IP.
The problem is that after 10 seconds, where the ban expires, if I continue running the ab
, the fail2ban log is now filled with:
Ignore 192.168.XX.XX, expired bantime
Ignore 192.168.XX.XX, expired bantime
Ignore 192.168.XX.XX, expired bantime
From that point onward, and for a very long time, no ban occurs. At the same time fail2ban log reveals processing, even if I stop ab
. If I wait long enough and confirm that the fail2ban log activity stops, then restarting the stress tests effectively bans the IP.
My questions are:
- What does this
expired bantime
exactly mean? - It seems that fail2ban will keep on processing stuff even though stress testing with
ab
has stopped a long time ago. Is there a possibility that there is a buffer of some sort on fail2ban that I could reduce, which would probably also solve my first problem?
This means that the ban if it would take place will be immediately expired due to your config, so unban would be called immediately after ban, what would make the banning process unnecessary.
The end of ban is calculated using formula:
This is happening because related to your configuration end of ban of lot of messages is probably smaller than now, so fail2ban filter ignoring this and is simply searching for further messages.
Another possibility could be that your banning action does not really work so the banned "intruder" (or rather simulated stress tester) is still able to produce messages, so this does overflooding the log.
Or fail2ban is simply unable to scroll over the log faster than you generates the messages.
Well this signaling indeed that something is not correct in your config: slow regex's, wrong action etc or even too many messages.
Please take a look at fail2ban wiki :: Best practice describing certain optimizations.
Not really. But you can probably reduce parasite log traffic if you would switch a procedure: