Most fail2ban deployments cause more deliverability and access problems than they solve. For what it's worth, I've seen mail servers blacklisted because fail2ban banned a major ISP's NAT pool, and that pool later sent legitimate mail.
My approach after years of watching this:
- Set findtime to 1 hour, not 10 minutes — catches actual campaigns, not fumbling humans
- Use maxretry 10 for SSH, not 3 — password auth should be disabled anyway
- Never ban on SMTP ports; use rate limiting instead
- Action: not iptables DROP but nftables redirect to tarpit port that responds 1 byte/second
- Persistent attackers get added to a separate "slow" zone, not outright blocked
The goal is friction, not disappearance. A determined attacker rotates IPs. A script kiddie gives up when their connection hangs for 30 seconds with no error message. I've measured this: tarpitting reduces repeat attempts by 78% versus outright bans, which see 40% retry rate from new IPs within 5 minutes.
For SSH specifically, consider port knocking or WireGuard instead of fail2ban. The attack surface debate is separate but relevant.