SSD Nodes Learn Hosting plans →
Guides Matt ConnorBy Matt Connor

CrowdSec vs fail2ban on a single VPS

fail2ban bans locally by default. CrowdSec trades alert data for a community blocklist. Pick one for an Ubuntu VPS with SSH and a reverse proxy.

CrowdSec vs fail2ban: the short answer

On a single VPS, the CrowdSec vs fail2ban choice turns on one question: will you send ban data to a vendor in exchange for a shared blocklist? Both tools read your logs and ban addresses that misbehave. fail2ban bans on the box and reports to nobody unless you add a reporting action. CrowdSec, by default, sends signal data to its Central API every time an alert fires, and you get a community blocklist back.

This page is for one Ubuntu server that runs SSH and a reverse proxy such as nginx. It does not cover a fleet. These are the versions read on 30 November 2026. The CrowdSec Security Engine is at v1.8.2, released 26 October 2026. The CrowdSec firewall bouncer is at v0.0.38, released 29 September 2026. fail2ban upstream is at 1.1.1, released 15 August 2026. Ubuntu installs an older fail2ban from its universe component: 1.1.0-9 on 26.04 LTS and 1.0.2-3ubuntu0.1 on 24.04 LTS.

Pick fail2ban if

  • You want no ban data to leave the server. Its default action bans locally and reports to nobody.
  • You mainly protect SSH. Ubuntu's package enables the sshd jail when you install it.
  • You want a package from Ubuntu's own archive, with no third-party apt repository.
  • You already have working fail2ban filters for your applications.

Pick CrowdSec if

  • You accept that alert data goes to CrowdSec's Central API, and you want the community blocklist it sends back.
  • You want web requests blocked inside the proxy. CrowdSec has bouncers with WAF (web application firewall) support for nginx, OpenResty, Traefik and HAProxy.
  • You want detection and blocking as separate parts, so one engine can feed bans to the firewall and to the proxy.
  • You are willing to add CrowdSec's own apt repository, because Ubuntu's crowdsec package is the old 1.4.6.

Whichever you pick, use one enforcer per service. The section on running both explains why. This page prints no RAM or CPU figures. No measured source was found, so measure both tools on your own server if resource use decides it for you.

How does CrowdSec split detection from blocking?

CrowdSec has two parts. The Security Engine reads logs, matches them against scenarios, and writes decisions (bans) to its Local API. A remediation component, which CrowdSec calls a bouncer, is separate software. It authenticates to the Local API with an API key, fetches the decisions, and enforces them.

The CrowdSec install page says it plainly: the Security Engine by itself is a detection engine and will not block anything. So if you install only the crowdsec package, decisions pile up in the Local API and no packet is dropped. You need a bouncer. For SSH and other non-web services, that is the firewall bouncer.

fail2ban is one daemon. A jail joins a filter (a set of log patterns) to an action (usually a firewall rule). When an address matches too often, the action bans it. Detection and blocking live in the same process, so there is no separate part to forget.

Why does Ubuntu's apt install an old CrowdSec?

Ubuntu's universe component ships its own crowdsec package at version 1.4.6: 1.4.6-10.1 on 26.04 and 1.4.6-6ubuntu0.24.04.2 on 24.04. CrowdSec's install page tells you to make sure apt installs a version higher than 1.4.6, "otherwise you are installing an old and outdated version." The fix is CrowdSec's own repository, hosted on packagecloud.

CrowdSec's install script adds the signing key and the packagecloud source for you. Download it, read it, run it, then check which version apt will pick:

sudo apt update && sudo apt install -y curl gnupg
curl -fsSL https://install.crowdsec.net -o crowdsec-repo.sh
less crowdsec-repo.sh
sudo sh crowdsec-repo.sh
sudo apt update
apt-cache policy crowdsec

Read the Candidate: line of apt-cache policy. It must be higher than 1.4.6 and come from packagecloud.io. If it is 1.4.6, apt is still choosing Ubuntu's package. The docs page shows the same script as a one-line pipe, curl -s https://install.crowdsec.net | sudo sh. Downloading it first lets you read what it writes before it runs as root: a key in /etc/apt/keyrings/ and a source file in /etc/apt/sources.list.d/.

The extra step on Ubuntu Pro and ESM machines

ESM (Expanded Security Maintenance) is the extra update stream that Ubuntu Pro turns on. CrowdSec's docs say that on an ESM or Pro machine you must change the package weights to get the current version. The fix is a pin file:

printf 'Package: *\nPin: release o=packagecloud.io/crowdsec/crowdsec,a=any,n=any,c=main\nPin-Priority: 1001\n' | sudo tee /etc/apt/preferences.d/crowdsec
sudo apt update
apt-cache policy crowdsec

Know what this pin does before you keep it. The apt_preferences man page says a priority of 1000 or more installs that version even if this means a downgrade. The pin says Package: *, so it applies to every package CrowdSec's repository carries. That repository now wins over Ubuntu for all of them. This is the intended effect, but it reaches further than one package.

Install the engine and a firewall bouncer

sudo apt install crowdsec

The package has a debconf question that asks whether to register with the Central API. Its default answer is yes, and when the answer is yes the install runs cscli capi register. The question has medium priority, so whether apt shows it depends on your debconf settings. If it is not shown, the default applies.

The install also runs cscli setup unattended. This detects supported services on the box and sets up their Hub collections and log reading. Check that the SSH collection is there, and add it if it is missing:

sudo cscli collections list
sudo cscli collections install crowdsecurity/sshd
sudo systemctl reload crowdsec

The crowdsecurity/sshd collection holds the SSH log parsers and brute-force scenarios such as ssh-bf and ssh-slow-bf.

Now the bouncer. On 30 November 2026 the CrowdSec install page lists crowdsec-firewall-bouncer-iptables for non-web services such as SSH. The bouncer's own docs page also lists an nftables variant, crowdsec-firewall-bouncer-nftables, and tells you to pick the one that matches your firewall system. Check it with iptables -V: if the output mentions nf_tables, you are on nftables. The background is in how iptables and nftables relate on Ubuntu.

iptables -V
sudo apt install crowdsec-firewall-bouncer-nftables
sudo cscli bouncers list

Install the -iptables package instead if that matches your system. Do not install the package named plain crowdsec-firewall-bouncer: Ubuntu's archive ships that name at the older 0.0.25. Use sudo cscli bouncers list to check that your bouncer is registered with the Local API.

To prove that blocking works, CrowdSec's health check adds a one-minute ban on your own public IP. Its docs warn of a risk of self-lockout, so open your provider's web console first, or run the test from a second IP:

sudo cscli decisions add --ip 198.51.100.7 --duration 1m --reason "CrowdSec remediation test"

Replace 198.51.100.7 with your own public address.

What does CrowdSec send to its Central API?

Unless you opt out, the Local API pushes signal metadata to the Central API when an alert is generated. Per CrowdSec's Central API page, each signal holds:

  • The name of the scenario that was triggered.
  • The hash and version of that scenario.
  • The timestamp of the decision.
  • Your machine_id.
  • The offending IP address, with its geolocation when available.

There is more. At login the engine sends its list of enabled scenarios. It also reports the names and versions of its bouncers and its registered engines.

Alerts from custom and tainted scenarios are pushed by default too. A custom (local) scenario is one you wrote. A tainted one is a Hub item you changed. These two commands stop those alerts:

sudo cscli console disable custom
sudo cscli console disable tainted

They do not stop alerts from unmodified Hub scenarios, such as the SSH brute-force ones. So they do not turn sharing off. In the 1.8.2 source, two more Console options default to off: sharing manual decisions and sharing alert context. cscli console enroll turns manual decision sharing on.

Can you turn the Central API off completely?

Yes. CrowdSec's troubleshooting docs have a section on it: comment out the online_client section of config.yaml, then restart CrowdSec. In /etc/crowdsec/config.yaml, find online_client: under api: and then server:. Put a # in front of online_client: and in front of its credentials_path: line. Then restart and check:

sudo nano /etc/crowdsec/config.yaml
sudo systemctl restart crowdsec
sudo cscli capi status

There is no cscli capi disable command. cscli capi has only register and status.

The docs list the cost. Without the Central API, the engine no longer receives the community blocklist or Console blocklists. It no longer shares signals, and it cannot be managed from the Console. Local detection and remediation keep working.

A narrower switch exists. The sharing setting under online_client controls whether signals are shared, separately from the pull.community and pull.blocklists settings. In 1.8.2 all of these default to true. The docs say that changing sharing affects how many community blocklist IPs you download, depending on your plan. Free users who do not contribute signals get the Community Blocklist (Lite), capped at 3 thousand IPs. The same page describes the full Community list as 15 thousand IPs and Premium as up to 60 thousand. The full list requires regular signals from unmodified Hub scenarios. The docs do not say whether other traffic, such as the scenario list, stops when sharing is false. If you need zero outbound data, disable the Central API completely. A separate setting, disable_usage_metrics_export, defaults to false and stops usage metrics export to the Console.

How local is fail2ban?

fail2ban reads logs and updates the host firewall. Its upstream jail.conf sets the default action to %(action_)s, commented as "the simplest action to take: ban only". Nothing leaves the box with that action.

That stays true only while you keep it that way. fail2ban ships optional actions that do send data out. The abuseipdb action, for example, reports the banned IP and the matching log lines to AbuseIPDB's API. If you or a copied config enabled one, your server is reporting.

What does Ubuntu change in fail2ban's defaults?

Upstream fail2ban disables every jail. Its defaults are bantime = 10m, findtime = 10m and maxretry = 5. Ubuntu's package adds /etc/fail2ban/jail.d/defaults-debian.conf, and the two LTS releases differ:

  • On 26.04 it sets banaction = nftables, enables the sshd jail, and gives only that jail backend = systemd with a journal match on ssh.service.
  • On 24.04 it sets banaction = nftables and puts backend = systemd in [DEFAULT], so every jail reads the journal. It also enables sshd.

The 24.04 default is a trap for a reverse proxy. fail2ban's man page says logpath is not valid for the systemd backend. nginx writes to log files, not to the journal, so an nginx jail on 24.04 needs its own file backend. Put local changes in /etc/fail2ban/jail.local or a file in jail.d/, never in jail.conf:

[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 198.51.100.7

[nginx-http-auth]
enabled = true
backend = auto

fail2ban never bans the host's own addresses, because ignoreself defaults to true. The ignoreip line is commented out by default. Add your admin IP there so a mistyped password of your own does not ban you. Then restart and inspect:

sudo systemctl restart fail2ban
sudo fail2ban-client status sshd
sudo fail2ban-client get sshd ignoreip

The full SSH walkthrough is in setting up fail2ban for SSH on Ubuntu 24.04. Neither tool replaces key-only logins. Do the basics from hardening SSH on a VPS first, and treat bans as a way to cut log noise.

Why do Docker-published ports ignore both tools' bans?

Docker's docs say it plainly. Traffic to a published container port is diverted in the nat table, before it reaches the INPUT chain. To the host, that traffic is forwarded, not addressed to the box itself. A ban placed only on the input path never sees it. This is the same reason Docker ports bypass ufw.

Both tools ban on the input path by default:

  • fail2ban's nftables action, which Ubuntu selects, creates its own table f2b-table and hooks the input chain at priority -1. It rejects by default.
  • CrowdSec's firewall bouncer in iptables mode inserts rules only into INPUT by default.

With Docker's default iptables backend, user rules for container traffic belong in the DOCKER-USER chain. For the CrowdSec iptables bouncer, the docs say to add DOCKER-USER to the list of chains in /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml:

iptables_chains:
  - INPUT
  - DOCKER-USER

Then restart it with sudo systemctl restart crowdsec-firewall-bouncer. The nftables variant is different. The v0.0.38 config it ships hooks both input and forward, at priority -10, with deny_action: DROP, so its shipped config covers forwarded traffic. If an older config file has no nftables_hooks key, the code default is input only, so open your file and check. This was not tested against a Docker host.

For fail2ban, do not set chain = DOCKER-USER on a jail that uses the nftables action. In that action, chain is the name of fail2ban's own nftables chain (f2b-chain), so the setting does not move the ban into Docker's path. fail2ban's iptables action does take a chain setting, which defaults to INPUT. For a jail that watches a proxy container's log, one override is:

[nginx-http-auth]
enabled = true
backend = auto
logpath = /srv/proxy/logs/error.log
banaction = iptables[type=allports]
chain = DOCKER-USER

Set logpath to the host path where your container writes its log. allports matters because packets in DOCKER-USER have already been through DNAT (destination network address translation). Their destination port is the container's port, not the published one, so a port match could miss. DNAT does not change the source address, so a ban on the client IP still matches. This combination comes from Docker's docs and fail2ban's source. It was not tested here.

Docker 29.0.0 added an nftables backend. Docker calls it experimental and opt-in, and it has no DOCKER-USER chain. Docker says to create your own base chain on the forward hook instead. All of the DOCKER-USER advice above assumes the iptables backend.

Why does a reverse proxy or tunnel hide the real client IP?

Both tools ban the address they find in the log. If nginx sits behind a load balancer, a CDN or another proxy, its log holds that proxy's address. Then the wrong address gets banned, or nothing gets banned.

CrowdSec's docs say its parsers do not read the X-Forwarded-For header. The web server must put the real client IP into the log's address field before it writes the line. In nginx that is the realip module. It trusts the header only from addresses in set_real_ip_from. Its real_ip_header defaults to X-Real-IP, so set it to the header your proxy actually sends:

set_real_ip_from 203.0.113.5;
real_ip_header X-Forwarded-For;

List only your own proxy's addresses. Trust anything else and a client can write any IP into the header and get someone else banned. In Apache the same job is done by mod_remoteip. If Traefik is your proxy, CrowdSec's docs say both Traefik and the CrowdSec middleware must be told which upstream ranges to trust.

CrowdSec has a second trap here. Its default whitelist parser discards events from 127.0.0.1, ::1 and the private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) before they reach any scenario. A proxy container that logs a Docker bridge address therefore produces no detections at all. It also means a test from a private IP raises no alert.

Fixing the log fixes detection, not blocking. When a visitor reaches your server through a proxy, the packets arrive from the proxy's address. A host firewall rule that bans the visitor's real IP does not match them. The block has to happen where the real address is visible: in the proxy, or at the edge. For web apps, CrowdSec's install page recommends a bouncer with WAF support for nginx, OpenResty, Traefik or HAProxy instead of the firewall bouncer.

Cloudflare Tunnel is the extreme case. Cloudflare's docs say the origin sees the cloudflared process IP. HTTP apps can read the CF-Connecting-IP header. For SSH and other non-HTTP protocols, the original source IP is not available to the origin. So if you reach SSH through a tunnel, as in running services through Cloudflare Tunnel with no open ports, neither tool can ban a client by its real IP from the sshd log. Control access to that path at Cloudflare instead.

Should you run CrowdSec and fail2ban together?

No official guidance was found either way. CrowdSec's own blog presents CrowdSec as an alternative to fail2ban for SSH brute-force protection. Our advice is one enforcer per service.

Here is what overlapping bans do with the nftables versions of both. The CrowdSec bouncer hooks input at priority -10. fail2ban hooks input at priority -1. In nftables a drop is final, so a packet CrowdSec drops never reaches fail2ban's chain. Each tool keeps its own ban list. If you unban an address in one tool, the other tool's ban stays in place, and the address is still blocked. With iptables mode the rule order was not verified.

The two tools also block differently. fail2ban's nftables action rejects, and the CrowdSec bouncer drops. A client sees those as different errors, which connection refused versus timed out explains. If the symptom changes after you unban in one tool, check the other tool for a ban too.

If you do keep both, split the work. For example, keep fail2ban on SSH and use CrowdSec only for the proxy. Remove the SSH collection from CrowdSec so the two never watch the same log:

sudo cscli collections remove crowdsecurity/sshd
sudo systemctl reload crowdsec

When an address is stuck, look in both places:

sudo fail2ban-client status sshd
sudo fail2ban-client unban 198.51.100.7
sudo cscli decisions list -i 198.51.100.7
sudo cscli decisions delete -i 198.51.100.7

fail2ban-client unban removes the address from all jails and from fail2ban's database. To unban in one jail only, use sudo fail2ban-client set sshd unbanip 198.51.100.7. cscli decisions list shows local decisions. Add -a to include decisions from the Central API. To see what is actually loaded in the kernel, read how to list active firewall rules on Ubuntu.

Ban length differs too. fail2ban's upstream bantime is 10 minutes. CrowdSec's default profile bans for 4 hours.

FAQ

Does CrowdSec block anything right after I install it?

No. The Security Engine only detects. It writes decisions to its Local API, and a separate bouncer must enforce them. For SSH, install crowdsec-firewall-bouncer-nftables or crowdsec-firewall-bouncer-iptables from CrowdSec's repository, matching what iptables -V reports. Then run sudo cscli bouncers list to check that the bouncer is registered.

Why does apt install CrowdSec 1.4.6 on Ubuntu?

Ubuntu's universe component ships its own crowdsec package at 1.4.6, which CrowdSec's install page calls old and outdated. Add CrowdSec's packagecloud repository and check apt-cache policy crowdsec until the candidate is higher than 1.4.6. On Ubuntu Pro or ESM machines you also need CrowdSec's pin file in /etc/apt/preferences.d/, with priority 1001.

Can I use CrowdSec without sending data to CrowdSec?

Yes. Comment out the online_client block and its credentials_path line in /etc/crowdsec/config.yaml, then restart CrowdSec. Local detection and remediation keep working. You lose the community and Console blocklists, and the server can no longer be managed from the Console. The cscli console disable custom and cscli console disable tainted commands do not do this. They only stop alerts from scenarios you wrote or changed.

Why does fail2ban not stop attacks on my Docker container?

Docker diverts traffic to published ports in the nat table, before the INPUT chain. Ubuntu's fail2ban uses the nftables action, which bans on the input hook only, so forwarded container traffic never meets the ban. With Docker's iptables backend, put that jail's bans in DOCKER-USER, for example with banaction = iptables[type=allports] and chain = DOCKER-USER.

Can I run CrowdSec and fail2ban on the same VPS?

They can both run, but give each service only one of them. If both watch the SSH log, both ban the same address, and unbanning in one tool leaves the other tool's ban in place. Keep fail2ban on SSH and CrowdSec on the proxy, or move everything to one tool.

Was this article useful?

#crowdsec#fail2ban#ssh#firewall#intrusion-prevention#docker