From a000daa41219004251f703e7be26f4fdae8d5a39 Mon Sep 17 00:00:00 2001 From: Alfonso Date: Mon, 6 Feb 2023 11:45:21 +0100 Subject: [PATCH] Full path in the iptables command When running as root in cron, the iptables command was not found, so a _search_ path command is used instead the single command --- blocklist.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blocklist.sh b/blocklist.sh index be22c7a..9758114 100755 --- a/blocklist.sh +++ b/blocklist.sh @@ -32,6 +32,7 @@ echo "Downloading the most recent IP list from $ABUSE and adding them to abuseip ipset create abuseipdb hash:ip curl -s -H "key: $abuse_key" https://api.abuseipdb.com/api/v2/blacklist | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | xargs -L1 ipset add abuseipdb 2>&1 echo "Adding the iptables rules..." -iptables -I INPUT -m set --match-set crawler_bots src -j DROP -iptables -I INPUT -m set --match-set blocklistde src -j DROP -iptables -I INPUT -m set --match-set abuseipdb src -j DROP +$(whereis iptables | cut -d" " -f 2) -I INPUT -m set --match-set crawler_bots src -j DROP +#iptables -I INPUT -m set --match-set crawler_bots src -j DROP +$(whereis iptables | cut -d" " -f 2) -I INPUT -m set --match-set blocklistde src -j DROP +$(whereis iptables | cut -d" " -f 2) -I INPUT -m set --match-set abuseipdb src -j DROP