RousselTMLEARNING

Article · CrowdSec: From Discovery to Expertise

CrowdSec or Fail2ban?

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 #

📄 CrowdSec or Fail2ban: what are the differences? →

My progress

  • ⏱ Estimated time : ≈ 3 min

Sign in to track your progress and take notes. Sign in

💬 Ask a question

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...

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!