1. Two tools, two models #
What really sets them apart.
The same starting point #
Fail2ban and CrowdSec both read logs and ban abusive addresses. Fail2ban, written in Python, does so server by server: a filter (regular expression) counts failures in a jail, then an action sets a local firewall rule. CrowdSec separates these steps and makes them shareable.
The comparison #
| Fail2ban | CrowdSec | |
|---|---|---|
| Detection | Regular expressions and a counter per jail | Parsers and behavioral scenarios |
| Blocking | Local actions, mostly the firewall | Independent bouncers: firewall, proxy, CDN, application |
| Several servers | One configuration per server, no native sharing | Several agents and bouncers around one LAPI |
| Shared intelligence | No | Yes, community list (optional) |
| Content | Filters provided, to write or adapt | Hub of collections, updated with cscli |
| Remediations | Ban through actions | Ban, captcha, block page depending on the bouncer |
| Web application layer | Filters on logs | Also: AppSec WAF and virtual patching |
| Observability | fail2ban-client, logs | cscli metrics, Prometheus, console |
| Learning curve | Very simple on one server | More concepts to understand |
2. Which one to choose? #
Depending on your context.
Keep Fail2ban #
Fail2ban remains an excellent choice on a small isolated server, to protect SSH with no dependency or network service, when you need neither a dashboard nor sharing.
Choose CrowdSec #
- You manage several servers and want an attack seen on one to be blocked on all.
- You want to block at the reverse proxy, with a block page or captcha, not only at the firewall.
- You want to use community reputation to block before the first attack.
- You want to follow activity with Prometheus and Grafana.
3. Migrating safely #
Run both, then switch.
The method #
- Install CrowdSec without a bouncer, next to Fail2ban: it observes and blocks nothing.
- For one or two weeks, compare
cscli alerts listwith what Fail2ban bans, and spot false positives. - Add your trusted addresses to an allowlist.
- Install the bouncer, check blocking, then stop Fail2ban.
cscli alerts list --since 24h
sudo fail2ban-client status sshd
# Quand tout est prêt :
sudo systemctl disable --now fail2banAvoid duplicates. Two tools managing the same firewall chains make troubleshooting harder: likewise, do not install two firewall bouncers on one machine.
