RousselTMLEARNING

Observability

CrowdSec or Fail2ban: what are the differences?

Comparing CrowdSec and Fail2ban: detection, blocking, sharing, performance, multi-server, and how to migrate safely.

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.

Fail2ban works server by server; CrowdSec shares a Local API between agents and bouncers

The comparison #

Fail2banCrowdSec
DetectionRegular expressions and a counter per jailParsers and behavioral scenarios
BlockingLocal actions, mostly the firewallIndependent bouncers: firewall, proxy, CDN, application
Several serversOne configuration per server, no native sharingSeveral agents and bouncers around one LAPI
Shared intelligenceNoYes, community list (optional)
ContentFilters provided, to write or adaptHub of collections, updated with cscli
RemediationsBan through actionsBan, captcha, block page depending on the bouncer
Web application layerFilters on logsAlso: AppSec WAF and virtual patching
Observabilityfail2ban-client, logscscli metrics, Prometheus, console
Learning curveVery simple on one serverMore 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 #

  1. Install CrowdSec without a bouncer, next to Fail2ban: it observes and blocks nothing.
  2. For one or two weeks, compare cscli alerts list with what Fail2ban bans, and spot false positives.
  3. Add your trusted addresses to an allowlist.
  4. 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 fail2ban
Avoid duplicates. Two tools managing the same firewall chains make troubleshooting harder: likewise, do not install two firewall bouncers on one machine.

Sources #

Related articles

CrowdSec: understanding the collaborative firewall

What CrowdSec is, how it detects and blocks attacks: Security Engine, parsers, scenarios, Local API, Central …

Installing and configuring CrowdSec: packages, Docker, acquisition

Install CrowdSec with packages or Docker, understand its files, declare the logs to read, enroll the console …

CrowdSec collections, parsers and scenarios

The Hub, collections, the parser pipeline and scenarios: install, understand with cscli explain, write your o…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!