Version: 3.6.0 Configuration Method: Environment Variables (no YAML config file) Last Updated: 2026-03-04
crowdsec-blocklist-import is configured entirely through environment variables. This document provides a complete reference for all available configuration options, including required settings, optional parameters, and advanced features.
These variables must be set before the application can run. The application will not start without them.
| Variable | Description | Example |
|---|---|---|
| CROWDSEC_LAPI_URL | CrowdSec Local API URL | http://localhost:8080 |
| CROWDSEC_LAPI_KEY or CROWDSEC_LAPI_KEY_FILE | Bouncer API key or path to Docker secret file | key_abcd1234... or /run/secrets/lapi_key |
| CROWDSEC_MACHINE_ID | Machine identifier for authentication | blocklist-import |
| CROWDSEC_MACHINE_PASSWORD or CROWDSEC_MACHINE_PASSWORD_FILE | Machine password or path to Docker secret file | mypassword or /run/secrets/machine_password |
- Docker Secrets: Use the
_FILEsuffix to reference mounted secret files instead of passing credentials directly - LAPI_URL: Must include protocol (http/https) and port. Default is
http://localhost:8080 - Key vs Key_FILE: Provide either
CROWDSEC_LAPI_KEYORCROWDSEC_LAPI_KEY_FILE, not both - Password vs Password_FILE: Provide either
CROWDSEC_MACHINE_PASSWORDORCROWDSEC_MACHINE_PASSWORD_FILE, not both
Controls how blocklist decisions are created and managed in CrowdSec.
| Variable | Default | Description | Example |
|---|---|---|---|
| DECISION_DURATION | 24h |
How long decisions remain active | 48h, 168h, 1h |
| DECISION_REASON | external_blocklist |
Visible in cscli decisions list output |
blocklist-import |
| DECISION_TYPE | ban |
Decision action type | ban, captcha, throttle |
| DECISION_ORIGIN | blocklist-import |
Origin label for filtering and auditing | external-threat-feed |
| DECISION_SCENARIO | external/blocklist |
Scenario name for classification | external/malware |
- Duration Format: Supports Go duration format:
h(hours),m(minutes),s(seconds). CrowdSec may accept extended formats, buth,m,sare the verified standard units. - DECISION_TYPE: Valid values are
ban(block),captcha(challenge), orthrottle(rate limit) - DECISION_ORIGIN: Used to group and filter decisions; recommended to match service name
- DECISION_SCENARIO: Helps with alert routing and severity classification
Configure IP addresses and networks to exclude from blocklist imports.
| Variable | Description | Example |
|---|---|---|
| ALLOWLIST | Comma-separated IPv4/IPv6 addresses and CIDR ranges | 140.82.112.0/20,8.8.8.8,2001:4860:4860::8888 |
| ALLOWLIST_GITHUB | Automatically fetch and apply GitHub IP ranges | true, false |
- Multiple Formats: Supports individual IPs, CIDR notation, and IPv6 addresses
- Comma Separation: Use commas without spaces between entries
- GitHub IPs: When enabled, the application automatically fetches current GitHub IP ranges from the official API
- Precedence: Allowlisted IPs will never be imported as decisions, regardless of blocklist source
Controls import behavior, performance, and output formatting.
| Variable | Default | Description | Example |
|---|---|---|---|
| BATCH_SIZE | 1000 |
Number of IPs to process per API batch | 500, 2000, 5000 |
| FETCH_TIMEOUT | 60 |
HTTP fetch timeout in seconds | 30, 120 |
| MAX_RETRIES | 3 |
Retry count on failed imports | 1, 5, 10 |
| LOG_LEVEL | INFO |
Logging verbosity level | DEBUG, INFO, WARN, ERROR |
| DRY_RUN | false |
Preview import without applying decisions | true, false |
| CONSOLIDATE_ALERTS | false |
Combine all IPs into a single CrowdSec alert per run | true, false |
| MAX_DECISIONS | 0 |
Cap total decisions (existing + new). 0 = unlimited | 50000, 100000 |
- BATCH_SIZE: Larger batches improve throughput but consume more memory; adjust based on available resources
- FETCH_TIMEOUT: Increase for slow or unreliable network connections; decrease for fast-fail behavior
- MAX_RETRIES: Number of times to retry failed imports before skipping the blocklist
- LOG_LEVEL:
DEBUGproduces verbose output useful for troubleshooting;WARNandERRORminimize output - DRY_RUN: Validates configuration and shows what would be imported without modifying decisions
- CONSOLIDATE_ALERTS: When enabled, all IPs from all sources are sent in a single alert instead of one alert per source batch. This dramatically reduces alert count on the CrowdSec console, which is important for users on the free tier (500 alerts/month limit). Trade-off: per-source scenario tracking is replaced with a generic "all sources" label.
- MAX_DECISIONS: When set to a value greater than 0, the importer checks the count of existing CrowdSec decisions and only submits enough new IPs to reach the cap. For example, with
MAX_DECISIONS=50000and 40,000 existing decisions, only 10,000 new IPs will be imported. Useful for preventing ipset overflow on devices with hardware limits (e.g., UniFi firewalls). Set to0(default) for unlimited.
Controls Prometheus metrics and telemetry collection.
| Variable | Default | Description | Example |
|---|---|---|---|
| METRICS_ENABLED | true |
Enable Prometheus metrics collection | true, false |
| METRICS_PUSHGATEWAY_URL | localhost:9091 |
Prometheus Push Gateway endpoint | pushgateway:9091, http://10.0.0.5:9091 |
| TELEMETRY_ENABLED | true |
Enable anonymous usage telemetry | true, false |
- METRICS_ENABLED: When disabled, no metrics are collected or pushed
- METRICS_PUSHGATEWAY_URL: Must be accessible from the application container; include hostname/IP and port
- TELEMETRY_ENABLED: Anonymous telemetry helps improve the application; disable if required by policy
- Metrics Included: IPs imported, decisions created, blocklists processed, fetch failures, batch performance
Each blocklist source can be individually enabled or disabled. All blocklists default to true (enabled).
| Variable | Description | Default |
|---|---|---|
| ENABLE_IPSUM | IPsum aggregated threat intelligence (IPs appearing on 3+ blocklists) | true |
| ENABLE_SPAMHAUS | Spamhaus DROP list | true |
| ENABLE_BLOCKLIST_DE | Blocklist.de abuse IP database | true |
| ENABLE_FIREHOL | FireHOL threat intelligence lists | true |
| ENABLE_ABUSE_CH | Abuse.ch malware IP lists | true |
| ENABLE_EMERGING_THREATS | Emerging Threats ETopen IP reputation | true |
| ENABLE_BINARY_DEFENSE | Binary Defense Systems threat feed | true |
| ENABLE_BRUTEFORCE_BLOCKER | Bruteforce Blocker SSH/FTP attackers | true |
| ENABLE_DSHIELD | DShield Internet Storm Center list | true |
| ENABLE_CI_ARMY | CI Army malicious IP list | true |
| ENABLE_BOTVRIJ | Botvrij.eu bot C&C IP list | true |
| ENABLE_GREENSNOW | Greensnow cybersecurity threat list | true |
| ENABLE_STOPFORUMSPAM | Stop Forum Spam IP blacklist | true |
| ENABLE_TOR | Tor exit node IP addresses | true |
| ENABLE_SCANNERS | Shodan/Censys scanner IPs | true |
| ENABLE_ABUSE_IPDB | AbuseIPDB malicious IP database | true |
| ENABLE_CYBERCRIME_TRACKER | Abuse.ch Cybercrime Tracker C&C IPs | true |
| ENABLE_MONTY_SECURITY_C2 | Monty Security C&C server tracker | true |
| ENABLE_VXVAULT | VXvault malware sample repository IPs | true |
| ENABLE_SENTINEL | Sentinel Turris greylist (community-sourced threat intelligence) | true |
- Format: Set to
false(case-insensitive) to disable; any other value enables the blocklist - Partial Ingestion: Can enable/disable individual blocklists without affecting others
- Selective Import: Useful for testing, reducing import volume, or excluding sources with false positives
- Update Frequency: Each blocklist has its own update schedule; check individual source websites for refresh rates
For secure credential management in Docker/Kubernetes environments, use the _FILE suffix pattern.
Instead of passing secrets as plain environment variables:
CROWDSEC_LAPI_KEY=my_secret_key
Mount a Docker secret and reference it:
CROWDSEC_LAPI_KEY_FILE=/run/secrets/lapi_key
The following variables support the _FILE pattern:
CROWDSEC_LAPI_KEY_FILE(instead ofCROWDSEC_LAPI_KEY)CROWDSEC_MACHINE_PASSWORD_FILE(instead ofCROWDSEC_MACHINE_PASSWORD)ABUSEIPDB_API_KEY_FILE(instead ofABUSEIPDB_API_KEY)
services:
blocklist-import:
image: ghcr.io/wolffcatskyy/crowdsec-blocklist-import:latest
environment:
CROWDSEC_LAPI_URL: http://crowdsec:8080
CROWDSEC_MACHINE_ID: blocklist-import
CROWDSEC_LAPI_KEY_FILE: /run/secrets/lapi_key
CROWDSEC_MACHINE_PASSWORD_FILE: /run/secrets/machine_password
secrets:
- lapi_key
- machine_password
secrets:
lapi_key:
external: true
machine_password:
external: trueThe application supports loading environment variables from a .env file using python-dotenv.
# CrowdSec API Configuration
CROWDSEC_LAPI_URL=http://crowdsec:8080
CROWDSEC_LAPI_KEY=bouncer_key_abc123xyz
CROWDSEC_MACHINE_ID=blocklist-import
CROWDSEC_MACHINE_PASSWORD=machine_password_123
# Decision Configuration
DECISION_DURATION=48h
DECISION_TYPE=ban
DECISION_ORIGIN=external-blocklist
DECISION_SCENARIO=external/malware
# Allowlists
ALLOWLIST=140.82.112.0/20,8.8.8.8,1.1.1.1
ALLOWLIST_GITHUB=true
# Processing
BATCH_SIZE=2000
FETCH_TIMEOUT=45
MAX_RETRIES=5
LOG_LEVEL=INFO
DRY_RUN=false
# Metrics
METRICS_ENABLED=true
METRICS_PUSHGATEWAY_URL=pushgateway:9091
TELEMETRY_ENABLED=true
# Blocklist Toggles
ENABLE_IPSUM=true
ENABLE_SPAMHAUS=true
ENABLE_ABUSE_CH=true
ENABLE_TOR=false
.envfile is loaded automatically if present in the working directory- Environment variables override values from
.envfile _FILEvariables are resolved after.envloading
The application includes built-in validation for environment variables.
- Required Variable Checking: Confirms all required variables are set before startup
- Typo Detection: Suggests corrections for common misspellings (e.g.,
CROWDESC_LAPI_URLvs correctCROWDSEC_LAPI_URL) - Format Validation: Validates URLs, durations, numeric ranges, and boolean values
- Credentials Verification: Tests connectivity to CrowdSec LAPI before starting imports
When validation fails, the application provides clear error messages:
ERROR: Missing required variable: CROWDSEC_LAPI_KEY
Use CROWDSEC_LAPI_KEY_FILE instead to reference a Docker secret
ERROR: Invalid duration format for DECISION_DURATION: xyz
Expected format: 24h, 48h, 168h, 1h, 30m, etc.
All environment variables can be overridden via command-line flags. Flags take precedence over environment variables.
| Flag | Short | Type | Description |
|---|---|---|---|
--help |
-h |
Boolean | Display help message and exit |
--version |
-v |
Boolean | Display application version and exit |
| Flag | Short | Type | Description | Overrides |
|---|---|---|---|---|
--lapi-url |
String | CrowdSec LAPI URL | CROWDSEC_LAPI_URL | |
--lapi-key |
String | Bouncer API key | CROWDSEC_LAPI_KEY | |
--duration |
String | Decision duration | DECISION_DURATION | |
--batch-size |
Integer | IPs per batch | BATCH_SIZE |
| Flag | Short | Type | Description |
|---|---|---|---|
--dry-run |
-n |
Boolean | Preview without importing |
--debug |
-d |
Boolean | Enable debug logging |
--validate |
Boolean | Validate config and exit | |
--list-sources |
Boolean | List all blocklist sources and exit |
| Flag | Type | Description | Overrides |
|---|---|---|---|
--pushgateway-url |
String | Prometheus Push Gateway URL | METRICS_PUSHGATEWAY_URL |
--no-metrics |
Boolean | Disable metrics collection | METRICS_ENABLED=false |
# Display version
python blocklist_import.py -v
# Preview import without applying decisions
python blocklist_import.py --dry-run
# Override LAPI URL
python blocklist_import.py --lapi-url http://10.0.0.5:8080
# Set duration and batch size
python blocklist_import.py --duration 168h --batch-size 5000
# Validate configuration
python blocklist_import.py --validate
# List available blocklists
python blocklist_import.py --list-sources
# Enable debug logging
python blocklist_import.py --debug
# Disable metrics
python blocklist_import.py --no-metrics
# Combine multiple flags
python blocklist_import.py --dry-run --debug --batch-size 3000Required environment variables only:
CROWDSEC_LAPI_URL=http://localhost:8080
CROWDSEC_LAPI_KEY=my_bouncer_key
CROWDSEC_MACHINE_ID=blocklist-import
CROWDSEC_MACHINE_PASSWORD=my_passwordRecommended settings for production deployments:
# API Configuration
CROWDSEC_LAPI_URL=http://crowdsec:8080
CROWDSEC_LAPI_KEY_FILE=/run/secrets/lapi_key
CROWDSEC_MACHINE_ID=blocklist-import-prod
CROWDSEC_MACHINE_PASSWORD_FILE=/run/secrets/machine_password
# Decision Configuration
DECISION_DURATION=48h
DECISION_TYPE=ban
DECISION_ORIGIN=external-blocklist
DECISION_REASON=malicious_ip_detected
DECISION_SCENARIO=external/malware
# Allowlists
ALLOWLIST=140.82.112.0/20,8.8.8.8,1.1.1.1,208.67.222.222
ALLOWLIST_GITHUB=true
# Processing
BATCH_SIZE=2000
FETCH_TIMEOUT=60
MAX_RETRIES=3
LOG_LEVEL=INFO
DRY_RUN=false
# Metrics
METRICS_ENABLED=true
METRICS_PUSHGATEWAY_URL=prometheus-pushgateway:9091
TELEMETRY_ENABLED=false
# Selective Blocklists
ENABLE_SPAMHAUS=true
ENABLE_ABUSE_CH=true
ENABLE_BLOCKLIST_DE=true
ENABLE_EMERGING_THREATS=true
ENABLE_TOR=true
ENABLE_SCANNERS=falseDevelopment/testing setup with dry-run and debug logging:
CROWDSEC_LAPI_URL=http://localhost:8080
CROWDSEC_LAPI_KEY=test_key_123
CROWDSEC_MACHINE_ID=blocklist-import-test
CROWDSEC_MACHINE_PASSWORD=test_password
DECISION_DURATION=1h
BATCH_SIZE=500
FETCH_TIMEOUT=30
LOG_LEVEL=DEBUG
DRY_RUN=true
METRICS_ENABLED=false
TELEMETRY_ENABLED=falseConfiguration values are loaded in the following order (later sources override earlier ones):
- Default values in the application code
.envfile in the working directory- Environment variables in the shell/container
_FILEvariables (Docker secrets, read and override parent variable)- Command-line flags (highest priority, always override)
Example:
# 1. Code default: LOG_LEVEL=INFO
# 2. .env file: LOG_LEVEL=WARN
# 3. Environment: LOG_LEVEL=DEBUG
# Result: DEBUG (environment variable wins)Reduce false positives by importing only trusted sources:
ENABLE_IPSUM=true
ENABLE_SPAMHAUS=true
ENABLE_ABUSE_CH=true
ENABLE_EMERGING_THREATS=true
ENABLE_BLOCKLIST_DE=true
# Disable less reliable or specialized sources
ENABLE_TOR=false
ENABLE_STOPFORUMSPAM=false
ENABLE_CI_ARMY=false
ENABLE_BOTVRIJ=false
ENABLE_GREENSNOW=falseEnable all available threat intelligence sources:
# Leave all ENABLE_* variables unset or set to true (default)
# All 19 blocklists will be importedPrevent blocking of CDN and cloud provider IP ranges:
ALLOWLIST=13.32.0.0/11,13.33.0.0/16,13.34.0.0/16,13.35.0.0/16,13.36.0.0/14,13.39.0.0/17,13.40.0.0/16,13.41.0.0/16,143.204.0.0/16,144.220.0.0/16,150.222.0.0/16,52.0.0.0/8,54.0.0.0/8,99.77.0.0/16
# Additional: Auto-allow GitHub, Cloudflare, AWS, Google, Microsoft
ALLOWLIST_GITHUB=trueTest mode with auto-expiring decisions:
DECISION_DURATION=1h
DRY_RUN=false
LOG_LEVEL=DEBUG
FETCH_TIMEOUT=30
MAX_RETRIES=1Optimize for performance with large IP lists:
BATCH_SIZE=5000
FETCH_TIMEOUT=120
MAX_RETRIES=5
LOG_LEVEL=WARN
METRICS_ENABLED=true
TELEMETRY_ENABLED=trueCause: One or more required variables are not set.
Solution: Ensure all required variables are set:
echo $CROWDSEC_LAPI_URL
echo $CROWDSEC_LAPI_KEY
echo $CROWDSEC_MACHINE_ID
echo $CROWDSEC_MACHINE_PASSWORDCause: LAPI URL is incorrect or CrowdSec is not accessible.
Solution: Verify connectivity:
curl http://localhost:8080/health
# Or with custom URL
curl http://your-crowdsec-host:8080/healthCause: DECISION_DURATION uses wrong format.
Solution: Use Go duration format:
# CORRECT:
DECISION_DURATION=24h # 24 hours
DECISION_DURATION=48h # 48 hours
DECISION_DURATION=168h # 7 days (168 hours)
DECISION_DURATION=1h30m # 1 hour 30 minutes
# INCORRECT:
DECISION_DURATION=24 # Missing unit
DECISION_DURATION=1 day # Space and long form not supportedCause: _FILE path is incorrect or file doesn't exist.
Solution: Verify the secret file exists and is readable:
# Inside the container
ls -la /run/secrets/lapi_key
cat /run/secrets/lapi_keyCause: Push Gateway URL is unreachable or metrics are disabled.
Solution: Check configuration:
echo $METRICS_ENABLED
echo $METRICS_PUSHGATEWAY_URL
# Test connectivity from container
curl http://localhost:9091/metrics-
Use Docker Secrets: Never pass credentials as plain environment variables in production. Use
_FILEsuffix pattern with mounted secrets. -
Enable Metrics: Leave
METRICS_ENABLED=truein production for monitoring and alerting on import failures. -
Set Appropriate Allowlists: Configure
ALLOWLISTto prevent blocking trusted IP ranges (CDN, cloud providers, internal services). -
Test with Dry-Run: Always test configuration changes with
DRY_RUN=trueor--dry-runflag before applying to production. -
Log Level in Production: Use
LOG_LEVEL=INFOorLOG_LEVEL=WARNto avoid excessive disk usage from debug logs. -
Reasonable Batch Size: Start with
BATCH_SIZE=1000and adjust based on available memory and API response times. -
Selective Blocklists: Disable blocklists that generate false positives in your environment (e.g.,
ENABLE_TOR=falseif Tor access is needed). -
Monitor Decision Duration: Choose
DECISION_DURATIONbased on your threat model; shorter durations reduce impact of false positives. -
Use .env Files: For local development, use a
.envfile to avoid setting environment variables manually. -
Regular Validation: Run
--validateflag periodically to catch configuration drift or typos.
- Configuration Reference: See config-reference.md (this document) for all environment variables and CLI flags
- Troubleshooting: See troubleshooting.md for common issues and solutions
- CrowdSec Documentation: https://docs.crowdsec.net
- FAQ: See faq.md for frequently asked questions
- Examples: See examples.md for deployment and configuration examples
For issues or questions:
- Check the Troubleshooting Configuration section above
- Run
python blocklist_import.py --validateto verify configuration - Enable
LOG_LEVEL=DEBUGfor detailed error information - Review CrowdSec LAPI logs for connection issues