basforge

Search titles, text and the “If it doesn’t work” cases.

    RU
    Cheat sheetHomelabCrowdSec

    cscli and bouncers: everyday commands

    Who is banned and why, how to unban your own address, whether a bouncer is alive, what CrowdSec reads from the logs. If CrowdSec runs in a container, prefix every cscli with docker exec crowdsec; on the host, no prefix is needed.

    Bans

    Command What it does
    cscli decisions list who is banned now, why, how long is left
    cscli decisions list --ip <IP> whether there’s a decision for this address
    cscli decisions add --ip <IP> --duration 2m --reason test a 2-minute ban — checks the bouncers work
    cscli decisions delete --ip <IP> lifts a ban, for example from your own address

    Alerts

    Command What it does
    cscli alerts list --limit 10 the latest scenario hits
    cscli alerts inspect <id> -d details: which log lines led to the ban

    Bouncers

    Command What it does
    cscli bouncers list every bouncer and its last contact (Last API pull) — is it alive
    cscli bouncers add <name> issues a key for a new bouncer; the key is shown once
    cscli bouncers delete <name> revokes the key; every <name>@<IP> entry goes with it
    cscli bouncers prune -d 168h --force deletes entries that haven’t contacted LAPI for a week

    Entries like <name>@172.18.0.x are the same bouncer coming from a container’s new address after it was recreated. The live one has a fresh Last API pull. Such an entry can’t be deleted by name — only with prune.

    What CrowdSec reads and how it parses it

    Command What it does
    cscli metrics summary: sources, parsers, scenarios, bouncer requests
    cscli metrics show acquisition lines read per source — is the source alive
    cscli explain --file /var/log/auth.log --type syslog how CrowdSec parses a file’s lines — does the parser fit

    Collections and the hub

    Command What it does
    cscli hub update refreshes the list of what the hub has
    cscli hub upgrade upgrades installed collections, parsers, scenarios
    cscli collections list what’s installed
    cscli collections install crowdsecurity/nginx installs a collection; also add it to COLLECTIONS in compose so it survives a recreate
    Command What it does
    cscli capi status is CrowdSec connected to the shared blocklists (CAPI)
    cscli lapi status does the local API answer — the one bouncers talk to

    The bouncer on the host

    Command What it does
    systemctl status crowdsec-firewall-bouncer is it running
    nft list table ip crowdsec | grep hook which hooks it sits on; you need input and forward (Docker ports bypass the input chain)
    nft list table ip crowdsec | grep -A1 'counter crowdsec' counters: packets dropped per list

    Common questions

    • Ban duration is duration: in profiles.yaml; after editing, docker compose restart crowdsec. Only new decisions get the new duration.
    • A new source is a file in acquis.d/ plus a restart. Whether it was picked up shows in cscli metrics show acquisition.
    • crowdsecurity/base-http-scenarios includes http-probing — a ban for a burst of 404s on /.env, /.git, wp-admin and the like.