init-debian/setup-crowdsec.sh
2026-01-29 01:57:09 +08:00

50 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
setup(){
echo "crowdsec crowdsec-firewall-bouncer-iptables" | $AWD/install.sh
echo -e "db_config:
use_wal: true" | tee /etc/crowdsec/config.yaml.local
echo -e "name: crowdsecurity/whitelists
description: "Whitelist events from custom ip addresses"
whitelist:
reason: "private ip ranges"
ip:
- "127.0.0.1"
- "::1"
cidr:
- "192.168.0.0/16"
- "10.0.0.0/8"
- "172.16.0.0/12"
- "fc00::/7"
# expression:
# - "'foo.com' in evt.Meta.source_ip.reverse"
" | tee /etc/crowdsec/parsers/s02-enrich/custom-whitelists.yaml
sed -i -r "s/.*DOCKER-USER.*/ - DOCKER-USER/g" /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
systemctl reload crowdsec
}
usage(){
echo "Usage: $0 [OPTIONS]";
echo "OPTIONS:";
echo " -h show this help";
}
while getopts ":h" OPT; do
case $OPT in
h)
usage;
;;
?)
echo "Invalid Option: -$OPTARG";
usage;
exit 1;;
esac;
done;
setup;