What Is CrowdSec?
CrowdSec is a modern, open-source intrusion prevention system. It analyzes logs, detects attacks, and applies remediation (blocking IPs). Its community-based threat intelligence shares attack data across all installations.
Installation
curl -s https://install.crowdsec.net | sudo sh
sudo apt install -y crowdsec crowdsec-firewall-bouncer-iptablesHow It Works
- Log parsing — CrowdSec reads logs from Nginx, SSH, etc.
- Scenario matching — detects brute force, scanning, exploitation attempts
- Decision — creates a ban decision for the offending IP
- Bouncer — the firewall bouncer enforces the ban
Check Status
# View active decisions (bans)
sudo cscli decisions list
# View installed scenarios
sudo cscli scenarios list
# View metrics
sudo cscli metricsInstall Additional Scenarios
# Browse available scenarios
sudo cscli hub list
# Install collections for common services
sudo cscli collections install crowdsecurity/nginx
sudo cscli collections install crowdsecurity/sshd
sudo cscli collections install crowdsecurity/linux
sudo systemctl reload crowdsecManual IP Management
# Ban an IP for 24 hours
sudo cscli decisions add --ip 1.2.3.4 --duration 24h --reason "manual ban"
# Unban an IP
sudo cscli decisions delete --ip 1.2.3.4
# Whitelist an IP
sudo cscli parsers install crowdsecurity/whitelists
# Edit /etc/crowdsec/parsers/s02-enrich/whitelists.yamlCrowdSec vs Fail2Ban
| Feature | CrowdSec | Fail2Ban |
|---|---|---|
| Threat intelligence | Community-shared | Local only |
| Performance | Go-based, fast | Python, slower |
| Bouncers | Multiple (firewall, Nginx, Cloudflare) | iptables only |
| Dashboard | Web console available | CLI only |