We use fail2ban on a number of our servers for blocking brute-force attempts against services like SSH, SMTP, IMAP, SIP, etc, and it works very well. However, we get a lot of false positives under certain common circumstances.
Most of our clients are small businesses. So all of their users are on a local LAN behind a NAT'd firewall. So it's common for 10 users to authenticate with, say, their email account just fine. But then one user enters the credentials wrong a few times, and the entire office (coming from a single public IP) is banned on our side.
I'd like for fail2ban to have a bit of intelligence to its process. Something along the lines of "If we see successful authentications from this IP address, then let's whitelist it for a bit, because future failed logins are almost certainly genuine failures and not brute-force attacks."
We have clients with static IPs at their offices and those with dynamic IPs. Manually whitelisting the dynamic IPs is obviously a no-go. But even for static IPs it would be a nightmare to try to manage those manually. As a brute-force IP is banned for a period of time, it'd be good to auto-whitelist an IP for a period of time once we detect a successful authentication attempt from it so that it can't be banned.
Is this something that can be done with some clever fail2ban rules?