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.
Sources #
My progress
Sign in to track your progress and take notes. Sign in
Recommended Articles
CrowdSec: understanding the collaborative firewall
What CrowdSec is, how it detects and blocks attacks: Security Engine, parsers, scenarios, Local A...
CrowdSec in production: best practices
Good habits for running CrowdSec in production: LAPI, keys, false positives, database, upgrades a...
CrowdSec bouncers: principles and firewall bouncer
Understanding CrowdSec bouncers: where to block, live and stream modes, API keys, decisions API, ...
Installing and configuring CrowdSec: packages, Docker, acquisition
Install CrowdSec with packages or Docker, understand its files, declare the logs to read, enroll ...
Protecting Traefik with CrowdSec: the bouncer plugin
Setting up the CrowdSec bouncer in Traefik: plugin, middleware, stream and live modes, real IP be...
CrowdSec bouncers for Nginx, Apache and HAProxy
Setting up CrowdSec bouncers for Nginx, OpenResty, Apache and HAProxy SPOA: configuration, block ...
CrowdSec bouncers: Cloudflare, network devices, Kubernetes and custom bouncer
Block at the CDN with Cloudflare Workers, feed pfSense or MikroTik with Blocklist Mirror, protect...
Decisions, profiles, allowlists and AppSec in CrowdSec
Manage decisions with cscli, adapt block duration and type with profiles, avoid false positives w...
CrowdSec observability: banned IPs, blocked attacks, Prometheus and Grafana
Monitoring CrowdSec: cscli metrics, banned IPs, detected attacks, volume blocked by bouncers, Pro...