Skip to content

Configuration Overview

cs-routeros-bouncer can be configured via YAML file and/or environment variables. Environment variables override values from the config file.

When running the binary directly, pass the config path with -c unless all required settings are supplied via environment variables:

Terminal window
cs-routeros-bouncer -c /path/to/config.yaml

Deployment helpers choose their own paths:

Deployment methodConfig path used
setup systemd service/etc/cs-routeros-bouncer/cs-routeros-bouncer.yaml
Docker imageEnvironment variables by default; /etc/cs-routeros-bouncer/config.yaml is auto-loaded if mounted
Direct binary executionNo implicit file; use -c

YAML string values may contain explicit ${VAR} placeholders. Only braced placeholders are expanded; literal $ characters in secrets are preserved.

A full annotated reference is included in the repository at config/cs-routeros-bouncer.yaml.

All options at a glance. See the dedicated pages for detailed descriptions.

The essential settings to get the bouncer running. Most deployments only need these.

Config KeyEnv VariableDefaultDescription
crowdsec.api_urlCROWDSEC_URLhttp://localhost:8080/CrowdSec LAPI URL
crowdsec.api_keyCROWDSEC_BOUNCER_API_KEY(required)Bouncer API key
mikrotik.addressMIKROTIK_HOST192.168.0.1:8728RouterOS API address (host:port)
mikrotik.usernameMIKROTIK_USERcrowdsecAPI username
mikrotik.passwordMIKROTIK_PASS(required)API password
firewall.ipv4.enabledFIREWALL_IPV4_ENABLEDtrueEnable IPv4 blocking
firewall.ipv6.enabledFIREWALL_IPV6_ENABLEDtrueEnable IPv6 blocking
firewall.filter.enabledFIREWALL_FILTER_ENABLEDtrueCreate filter firewall rules
firewall.raw.enabledFIREWALL_RAW_ENABLEDtrueCreate raw/prerouting rules
firewall.deny_actionFIREWALL_DENY_ACTIONdropAction: drop or reject
logging.levelLOG_LEVELinfoLog level: debug, info, warn, error

Fine-tuning options for decision filtering, TLS, performance, firewall customization, and observability. The defaults work well for most setups.

Config KeyEnv VariableDefaultDescription
crowdsec.update_frequencyCROWDSEC_UPDATE_FREQUENCY10sPoll interval
crowdsec.reconciliation_intervalCROWDSEC_RECONCILIATION_INTERVAL15mPeriodic address-list reconciliation (0 = disabled, minimum 1m)
crowdsec.lapi_metrics_intervalCROWDSEC_LAPI_METRICS_INTERVAL15mUsage metrics reporting interval (0 = disabled)
crowdsec.originsCROWDSEC_ORIGINS[] (all)Filter by origin
crowdsec.scopesCROWDSEC_SCOPES["ip","range"]Decision scopes
crowdsec.supported_decisions_typesCROWDSEC_DECISIONS_TYPES["ban"]Decision types (only ban is implemented)
crowdsec.scenarios_containingCROWDSEC_SCENARIOS_CONTAINING[]Include only matching scenarios
crowdsec.scenarios_not_containingCROWDSEC_SCENARIOS_NOT_CONTAINING[]Exclude matching scenarios
crowdsec.retry_initial_connectCROWDSEC_RETRY_INITIAL_CONNECTtrueRetry on startup
crowdsec.insecure_skip_verifyCROWDSEC_INSECURE_SKIP_VERIFYfalseSkip TLS verify
crowdsec.cert_pathCROWDSEC_CERT_PATHClient cert path
crowdsec.key_pathCROWDSEC_KEY_PATHClient key path
crowdsec.ca_cert_pathCROWDSEC_CA_CERT_PATHCA cert path

CROWDSEC_ORIGINS is space-separated when set as an environment variable, for example CROWDSEC_ORIGINS="crowdsec cscli".

Config KeyEnv VariableDefaultDescription
mikrotik.tlsMIKROTIK_TLSfalseUse TLS
mikrotik.tls_insecureMIKROTIK_TLS_INSECUREfalseSkip TLS verify
mikrotik.connection_timeoutMIKROTIK_CONN_TIMEOUT10sConnect timeout
mikrotik.command_timeoutMIKROTIK_CMD_TIMEOUT30sCommand timeout
mikrotik.pool_sizeMIKROTIK_POOL_SIZE4Parallel API connections (1–20)
Config KeyEnv VariableDefaultDescription
firewall.ipv4.address_listFIREWALL_IPV4_ADDRESS_LISTcrowdsec-bannedIPv4 list name
firewall.ipv6.address_listFIREWALL_IPV6_ADDRESS_LISTcrowdsec6-bannedIPv6 list name
firewall.filter.chainsFIREWALL_FILTER_CHAINS["input"]Filter chains; comma-separated env values trim whitespace around each entry
firewall.raw.chainsFIREWALL_RAW_CHAINS["prerouting"]Raw chains; comma-separated env values trim whitespace around each entry
firewall.rule_placementFIREWALL_RULE_PLACEMENTtopSimple string shorthand for global placement
firewall.rule_placement.strategyFIREWALL_RULE_PLACEMENT_STRATEGYtopObject-form strategy: top, bottom, position, before_comment, or after_comment
firewall.rule_placement.commentFIREWALL_RULE_PLACEMENT_COMMENTAnchor comment for comment placement
firewall.rule_placement.comment_matchFIREWALL_RULE_PLACEMENT_COMMENT_MATCHexactComment match mode: exact or contains
firewall.rule_placement.positionFIREWALL_RULE_PLACEMENT_POSITIONRequired zero-based RouterOS print position when strategy is position
firewall.rule_placement.fallbackFIREWALL_RULE_PLACEMENT_FALLBACKtopFallback for comment placement: top or bottom
firewall.rule_placement.filterYAML onlyFilter-table override; inherits unspecified fields from global placement
firewall.rule_placement.rawYAML onlyRaw-table override; inherits unspecified fields from global placement
firewall.ipv4.rule_placementYAML onlyIPv4-only placement override; inherits unspecified fields from global placement
firewall.ipv4.rule_placement.filterYAML onlyIPv4 filter-table override; inherits from global and IPv4 placement
firewall.ipv4.rule_placement.rawYAML onlyIPv4 raw-table override; inherits from global and IPv4 placement
firewall.ipv6.rule_placementYAML onlyIPv6-only placement override; inherits unspecified fields from global placement
firewall.ipv6.rule_placement.filterYAML onlyIPv6 filter-table override; inherits from global and IPv6 placement
firewall.ipv6.rule_placement.rawYAML onlyIPv6 raw-table override; inherits from global and IPv6 placement
firewall.comment_prefixFIREWALL_COMMENT_PREFIXcrowdsec-bouncerComment prefix
firewall.logFIREWALL_LOGfalseEnable rule logging
firewall.log_prefixFIREWALL_LOG_PREFIXcrowdsec-bouncerGlobal log prefix
firewall.reject_withFIREWALL_REJECT_WITHReject type when deny_action=reject: icmp-network-unreachable, icmp-host-unreachable, icmp-port-unreachable, icmp-protocol-unreachable, icmp-network-prohibited, icmp-host-prohibited, icmp-admin-prohibited, tcp-reset
firewall.filter.log_prefixFIREWALL_FILTER_LOG_PREFIXOverride log prefix for filter rules
firewall.filter.connection_stateFIREWALL_FILTER_CONNECTION_STATEComma-separated states: new, established, related, invalid, untracked; whitespace around entries is trimmed; lowercase only, no negation
firewall.raw.log_prefixFIREWALL_RAW_LOG_PREFIXOverride log prefix for raw rules
firewall.block_input.interfaceFIREWALL_BLOCK_INPUT_INTERFACERestrict input/raw rules to interface (empty = all)
firewall.block_input.interface_listFIREWALL_BLOCK_INPUT_INTERFACE_LISTRestrict input/raw rules to interface list (empty = all)
firewall.block_input.whitelistFIREWALL_BLOCK_INPUT_WHITELISTAddress-list for input whitelist (accept before drop)
firewall.block_output.enabledFIREWALL_BLOCK_OUTPUTfalseBlock outbound
firewall.block_output.interfaceFIREWALL_BLOCK_OUTPUT_INTERFACEWAN interface
firewall.block_output.interface_listFIREWALL_BLOCK_OUTPUT_INTERFACE_LISTWAN interface list
firewall.block_output.log_prefixFIREWALL_BLOCK_OUTPUT_LOG_PREFIXOverride log prefix for output rules
firewall.block_output.passthrough_v4FIREWALL_BLOCK_OUTPUT_PASSTHROUGH_V4IPv4 client to bypass output blocking
firewall.block_output.passthrough_v4_listFIREWALL_BLOCK_OUTPUT_PASSTHROUGH_V4_LISTIPv4 list to bypass output blocking
firewall.block_output.passthrough_v6FIREWALL_BLOCK_OUTPUT_PASSTHROUGH_V6IPv6 client to bypass output blocking
firewall.block_output.passthrough_v6_listFIREWALL_BLOCK_OUTPUT_PASSTHROUGH_V6_LISTIPv6 list to bypass output blocking

Backward-compatible aliases such as FIREWALL_INPUT_* and FIREWALL_OUTPUT_* are still accepted for older deployments. Prefer the explicit FIREWALL_BLOCK_INPUT_* and FIREWALL_BLOCK_OUTPUT_* names in new configs.

Config KeyEnv VariableDefaultDescription
logging.formatLOG_FORMATtextLog format: text or json
logging.fileLOG_FILELog file path (empty = stdout only)
metrics.enabledMETRICS_ENABLEDfalseEnable Prometheus /metrics endpoint
metrics.listen_addrMETRICS_ADDR0.0.0.0Listen address
metrics.listen_portMETRICS_PORT2112Listen port
metrics.routeros_poll_intervalMETRICS_ROUTEROS_POLL_INTERVAL30sRouterOS system metrics poll interval (0 to disable)
metrics.track_processedMETRICS_TRACK_PROCESSEDtrueCreate passthrough counting rules for processed traffic metrics