···99mermaid: true
1010---
11111212+[Crowdsec](https://www.crowdsec.net/) is moderately known within the homelab community but the majority of knowledge available, both in the [official documentation](https://docs.crowdsec.net/docs/intro/) and other community article sources, is surface-level and tends to frame its use in the context of a **single machine** where all the web traffic, monitoring, and blocking takes place.
1313+1414+This is adequete for toy implementations and beginner usage but falls short in the homelab where:
1515+1616+1. web traffic can be distributed across mutliple machines/networks
1717+2. not all machines are created equal in terms of traffic volume and compute capacity
1818+1919+which is unfortunate because Crowdsec is *designed for distributed use* and it's where it shines the brightest. It's also the least documented and most confusing for scaling up.
2020+2121+In this article I lay out how to think about Crowdsec for scaling up in the homelab, attempt to fill the void beyond single-instance usage, and provide practical examples for implementing your own homelab-scale Crowdsec solution.
2222+1223## Crowdsec?
13241414-* What is crowdsec
1515-* Why should I use it?
1616-* Maybe explain WAF
2525+Crowdsec is a multi-component, network security solution designed to detect and prevent bad actors from exploiting your systems. At a high level, it does this by:
2626+2727+* *proactively* blocking known bad actors from a crowdsourced database
2828+* *reactively* detecting suspicious network activity and blocking the associated actor by...
2929+ * monitoring logs from across your systems (web servers, ssh, syslogs, iis, iptables, etc.)
3030+ * matching attack patterns from log lines
3131+3232+The solution is composed of:
3333+3434+* a crowdsec binary that can be run natively or using a docker container
3535+ * takes configuration through config files
3636+ * can behave as individual components described in [Key Concepts](#key-concepts) below, or can do everything at the same time as an All In One (AIO) solution
3737+* [Remediation Components](#bouncers), software that communicate with the crowdsec binary to apply rules to network software in order to block actors
3838+3939+### Why Should I Use It?
4040+4141+It's a fact of life on the public internet that bad actors *will* be probing and trying to exploit your services, if they are accessible. It doesn't matter the size of the web server, what is hosted on it, or how obscure you try to make it: someone will always try to exploit it.
4242+4343+Crowdsec is an extremely easy way to harden access and prevent bad actors from even attempting to exploit your services. You benefit greatly by being able proactively block threat actors that have already tried to attack other crowdsec users.
4444+4545+TODO add benefits of reactive detection:
4646+4747+* react to novel actors
4848+* benefit from community parsers and scenarios, zero barrier to leveraging these
4949+5050+### Why Should I Not Use It?
5151+5252+**If you do not have any services exposed to the internet** then Crowdsec may not be necessary for you. Using a properly configured Wireguard server or Tailscale for access to your network bypasses all of the common weakpoints an attacker would be able to probe.
5353+5454+**If you need a full IDS/IPS[^detection]** then Crowdsec may not be the best choice. It does not operate on your actual network interfaces, do deep packet inspection, capture or correlate actor activity across the network, or provide audit logs for detected activity. You are better off with something like [Suricata](https://suricata.io/).
5555+5656+**If you already use something like [fail2ban](https://github.com/fail2ban/fail2ban)** or have fail2ban configured with bespoke filtering Crowdsec may not have feature parity for you. Setting up fail2ban filters from scratch is much easier than creating your own log parsers and scenarios in Crowdsec.
17571858### Key Concepts
1959···23632464The Management instance is the "brains" of CrowdSec's security engine. In most non-enterprise settings there is only one Management instance that all other components talk to.
25656666+<details markdown=1>
6767+6868+<summary>Details</summary>
6969+2670The management functionality enables the CS app to:
27712872* Recieve decisions ("ban IP X for Y minutes") from [Log Processors](#log-processor)
···34783579Notably, the Management instance does *not* need acquisition config or hub collections/scenarios/etc installed on it. That is only needed on Log Processors.
36808181+</details>
8282+3783#### Log Processor
38843985The CrowdSec application can be deployed with log processing (acquisition) and scenario monitoring functionality. CS docs refer to this functionality as [Log Processing](https://docs.crowdsec.net/docs/next/log_processor/intro).
40864187There may be many Log Processor instances of the Crowdsec application, for example one per host. Log Processors are the "senses" (see/hear/touch) of the CrowdSec "brain". They all communicate back to a Management instance.
42888989+<details markdown=1>
9090+9191+<summary>Details</summary>
9292+4393When the CS app is used for Log Processing it:
44944595* Has user-defined configuration to tell it what [Data Sources](https://docs.crowdsec.net/docs/next/log_processor/data_sources/intro) to consume, known as [acquistion](https://docs.crowdsec.net/docs/next/log_processor/intro#acquistions)
···5010051101Note: Data Source, Parsers, and Scenarios can be installed as bundles called [**Collections**](https://app.crowdsec.net/hub/collections).
52102103103+</details>
104104+53105#### Bouncers
5410655107A Bouncer is an application, separate from the Crowdsec app, that is used to:
···5911160112Crowdsec docs refer to Boucers as [Remediation Components](https://docs.crowdsec.net/u/bouncers/intro). There may be many Bouncers, all communicating with a Management instance. Bouncers are the "weapons" used to react after the CrowdSec "brain" realizes there is an "attack" (decision from Log Processor).
61113114114+<details markdown=1>
115115+116116+<summary>Details</summary>
117117+62118Some examples of bouncers, and how they use Management:
6311964120* [Firewall](https://docs.crowdsec.net/u/bouncers/firewall) - gets all IPs from Decicions stored in the Management instance and applies them as `BLOCK` rules to a host's firewall application (`iptables` or `nftables`)
65121* [Traefik](https://plugins.traefik.io/plugins/6335346ca4caa9ddeffda116/crowdsec-bouncer-traefik-plugin) - Installed as a middleware. When a request is intercepted it queries the Management instance for the request IP. If the IP is banned it returns a 403.
6612267123CS develops and maintains a large list of Bouncers for all popular platforms.
124124+125125+</details>
6812669127## Why Is this post needed?
70128···128186129187* create bouncer api key in Management
130188* install bouncer component or configure for service
189189+190190+___
191191+192192+## Footnotes
193193+194194+[^detection]: Intrustion **Detection** System and Intrustion **Prevention** System