so according to docs… I do;
then add this to bouncer.yaml and change it to ipset and uncomment the set names…
[root@dca632 /usbstick 58°] grep . /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
mode: ipset
pid_dir: /var/run/
update_frequency: 10s
daemonize: true
log_mode: file
log_dir: /var/log/
log_level: info
api_url: http://localhost:8080/
api_key: ab317b204d675486dbad50d753dfb9d3
disable_ipv6: false
deny_action: DROP
deny_log: false
supported_decisions_types:
- ban
#to change log prefix
#deny_log_prefix: "crowdsec: "
#to change the blacklists name
blacklists_ipv4: crowdsec-blacklists
blacklists_ipv6: crowdsec6-blacklists
#if present, insert rule in those chains
iptables_chains:
- INPUT
- FORWARD
# - DOCKER-USER
then manually create the ipsets
ipset create crowdsec-blacklists hash:ip timeout 0 maxelem 150000
ipset create crowdsec6-blacklists hash:ip timeout 0 family inet6 maxelem 150000
iptables -I INPUT 1 -m set --match-set crowdsec-blacklists src -j DROP
ip6tables -I INPUT 1 -m set --match-set crowdsec6-blacklists src -j DROP
then I restart the service/s and get this;
time="13-01-2022 15:55:54" level=info msg="nftables initiated"
time="13-01-2022 15:55:54" level=info msg="Processing new and deleted decisions . . ."
time="13-01-2022 15:56:04" level=error msg="auth-api: auth with api key failed return nil response, error: dial tcp [::1]:8080: connect: connection refused"
time="13-01-2022 15:56:04" level=error msg="Get \"http://localhost:8080/v1/decisions/stream?startup=false\": dial tcp [::1]:8080: connect: connection refused"
[root@dca632 /usbstick 58°] ps www | grep -v grep | grep -E '(cs\-|crowd)'
13272 root 695m S /usr/bin/cs-firewall-bouncer -c /var/etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
[root@dca632 /usbstick 57°] ipset -L -n | grep crowd
crowdsec-blacklists
crowdsec6-blacklists
[root@dca632 /usbstick 57°] ipset -L crowdsec-blacklists
Name: crowdsec-blacklists
Type: hash:ip
Revision: 4
Header: family inet hashsize 1024 maxelem 150000 timeout 0
Size in memory: 200
References: 1
Number of entries: 0
Members:
[root@dca632 /usbstick 57°] ipset -L crowdsec6-blacklists
Name: crowdsec6-blacklists
Type: hash:ip
Revision: 4
Header: family inet6 hashsize 1024 maxelem 150000 timeout 0
Size in memory: 208
References: 1
Number of entries: 0
Members:
[root@dca632 /usbstick 56°] (ip6tables-save -c ;iptables-save -c) | grep -i crowd
[0:0] -A INPUT -m set --match-set crowdsec6-blacklists src -j DROP
[0:0] -A INPUT -m set --match-set crowdsec-blacklists src -j DROP
note: those instructions are cobbled together from 3 different sources…
i’ve tackled some hard services in my time… asterisk, radiusd, sophos puremessage… but this one surely should not be this difficult?
[root@dca632 /usbstick 58°] find /etc/crowdsec/
/etc/crowdsec/
/etc/crowdsec/acquis.yaml
/etc/crowdsec/bouncers
/etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
/etc/crowdsec/collections
/etc/crowdsec/collections/linux.yaml
/etc/crowdsec/collections/sshd.yaml
/etc/crowdsec/config.yaml
/etc/crowdsec/dev.yaml
/etc/crowdsec/hub
/etc/crowdsec/hub/.index.json
/etc/crowdsec/hub/collections
/etc/crowdsec/hub/collections/crowdsecurity
/etc/crowdsec/hub/collections/crowdsecurity/linux.yaml
/etc/crowdsec/hub/collections/crowdsecurity/sshd.yaml
/etc/crowdsec/hub/parsers
/etc/crowdsec/hub/parsers/s00-raw
/etc/crowdsec/hub/parsers/s00-raw/crowdsecurity
/etc/crowdsec/hub/parsers/s00-raw/crowdsecurity/syslog-logs.yaml
/etc/crowdsec/hub/parsers/s01-parse
/etc/crowdsec/hub/parsers/s01-parse/crowdsecurity
/etc/crowdsec/hub/parsers/s01-parse/crowdsecurity/sshd-logs.yaml
/etc/crowdsec/hub/parsers/s02-enrich
/etc/crowdsec/hub/parsers/s02-enrich/crowdsecurity
/etc/crowdsec/hub/parsers/s02-enrich/crowdsecurity/dateparse-enrich.yaml
/etc/crowdsec/hub/parsers/s02-enrich/crowdsecurity/geoip-enrich.yaml
/etc/crowdsec/hub/parsers/s02-enrich/crowdsecurity/whitelists.yaml
/etc/crowdsec/hub/scenarios
/etc/crowdsec/hub/scenarios/crowdsecurity
/etc/crowdsec/hub/scenarios/crowdsecurity/ssh-bf.yaml
/etc/crowdsec/hub/scenarios/crowdsecurity/ssh-slow-bf.yaml
/etc/crowdsec/local_api_credentials.yaml
/etc/crowdsec/online_api_credentials.yaml
/etc/crowdsec/patterns
/etc/crowdsec/patterns/aws
/etc/crowdsec/patterns/bacula
/etc/crowdsec/patterns/bro
/etc/crowdsec/patterns/cowrie_honeypot
/etc/crowdsec/patterns/exim
/etc/crowdsec/patterns/firewalls
/etc/crowdsec/patterns/haproxy
/etc/crowdsec/patterns/java
/etc/crowdsec/patterns/junos
/etc/crowdsec/patterns/linux-syslog
/etc/crowdsec/patterns/mcollective
/etc/crowdsec/patterns/modsecurity
/etc/crowdsec/patterns/mongodb
/etc/crowdsec/patterns/mysql
/etc/crowdsec/patterns/nagios
/etc/crowdsec/patterns/nginx
/etc/crowdsec/patterns/paths
/etc/crowdsec/patterns/postgresql
/etc/crowdsec/patterns/rails
/etc/crowdsec/patterns/redis
/etc/crowdsec/patterns/ruby
/etc/crowdsec/patterns/smb
/etc/crowdsec/patterns/ssh
/etc/crowdsec/patterns/tcpdump
/etc/crowdsec/postoverflows
/etc/crowdsec/profiles.yaml
/etc/crowdsec/scenarios
/etc/crowdsec/scenarios/ssh-bf.yaml
/etc/crowdsec/scenarios/ssh-slow-bf.yaml
/etc/crowdsec/simulation.yaml
/etc/crowdsec/user.yaml
/etc/crowdsec/parsers
/etc/crowdsec/parsers/s00-raw
/etc/crowdsec/parsers/s00-raw/syslog-logs.yaml
/etc/crowdsec/parsers/s01-parse
/etc/crowdsec/parsers/s01-parse/sshd-logs.yaml
/etc/crowdsec/parsers/s02-enrich
/etc/crowdsec/parsers/s02-enrich/dateparse-enrich.yaml
/etc/crowdsec/parsers/s02-enrich/geoip-enrich.yaml
/etc/crowdsec/parsers/s02-enrich/whitelists.yaml
[root@dca632 /usbstick 57°] cat /etc/config/crowdsec
config crowdsec 'crowdsec'
option data_dir '/srv/crowdsec/data'
option db_path '/srv/crowdsec/data/crowdsec.db'
[root@dca632 /usbstick 57°] find /srv/crowdsec/
/srv/crowdsec/
/srv/crowdsec/data
/srv/crowdsec/data/crowdsec.db
[root@dca632 /usbstick 58°] lsof -i -nP | grep -E '(8080|6060)'
[empty]
[root@dca632 /usbstick 58°] tail -n5 /var/log/crowdsec.log
time="13-01-2022 15:55:57" level=warning msg="No matching files for pattern /var/log/apache2/*.log" type=file
time="13-01-2022 15:55:57" level=error msg="Failed to notify(sent: false): <nil>"
time="13-01-2022 15:55:57" level=warning msg="Starting processing data"
time="13-01-2022 15:55:57" level=info msg="Error machine login for 215b285b4abe4fc7a2b66089c460ae9dadrEYfHrDXaJB1J1 : ent: machine not found "
time="13-01-2022 15:55:57" level=fatal msg="starting outputs error : authenticate watcher (215b285b4abe4fc7a2b66089c460ae9dadrEYfHrDXaJB1J1): Post \"http://127.0.0.1:8080/v1/watchers/login\": API error: ent: machine not found"
[root@dca632 /usbstick 58°] crowdsec -version
2022/01/13 16:22:43 version: v1.2.1-openwrt
2022/01/13 16:22:43 Codename: alphaga
2022/01/13 16:22:43 BuildDate: 1641673875
2022/01/13 16:22:43 GoVersion:
2022/01/13 16:22:43 Constraint_parser: >= 1.0, <= 2.0
2022/01/13 16:22:43 Constraint_scenario: >= 1.0, < 3.0
2022/01/13 16:22:43 Constraint_api: v1
2022/01/13 16:22:43 Constraint_acquis: >= 1.0, < 2.0
[root@dca632 /usbstick 57°] cs-firewall-bouncer -V
version: v0.0.18-openwrt
BuildDate:
GoVersion: