From 73ffeee0d1ece9c140d0ab6b06325ed71305d425 Mon Sep 17 00:00:00 2001 From: Josef 'veloc1ty' Stautner Date: Tue, 27 Oct 2015 18:28:46 +0100 Subject: [PATCH] Full path to iptables --- blocklist-update.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/blocklist-update.sh b/blocklist-update.sh index 254442f..19e93d7 100644 --- a/blocklist-update.sh +++ b/blocklist-update.sh @@ -15,6 +15,7 @@ TO_DOWNLOAD[2]="http://lists.blocklist.de/lists/apache.txt" CHAINNAME="blocklist-de" ACTION="REJECT" # Can be DROP PRINT_REPORT=1 +IPTABLES_PATH="/sbin/iptables" ########## Do not edit anything below this line ########## @@ -50,14 +51,14 @@ amountAfterSortAndUnique=`cat $fileFiltered | wc -l` # ## Create chain if it does not exist # -iptables --new-chain $CHAINNAME >/dev/null 2>&1 +$IPTABLES_PATH --new-chain $CHAINNAME >/dev/null 2>&1 # Insert rule (if necesarry) into INPUT chain so the chain above will also be used -if [ `iptables -L INPUT | grep $CHAINNAME | wc -l` -eq 0 ] +if [ `$IPTABLES_PATH -L INPUT | grep $CHAINNAME | wc -l` -eq 0 ] then # Insert rule because it is not present - iptables -I INPUT -j $CHAINNAME + $IPTABLES_PATH -I INPUT -j $CHAINNAME fi @@ -68,7 +69,7 @@ while read currentIP do # Check via command - iptables -C $CHAINNAME -s $currentIP -j $ACTION >/dev/null 2>&1 + $IPTABLES_PATH -C $CHAINNAME -s $currentIP -j $ACTION >/dev/null 2>&1 # Now we have to check the exit code of iptables via $? # @@ -79,7 +80,7 @@ do then # Append the IP - iptables -A $CHAINNAME -s $currentIP -j $ACTION >/dev/null 2>&1 + $IPTABLES_PATH -A $CHAINNAME -s $currentIP -j $ACTION >/dev/null 2>&1 # Increment the counter amountInserted=$((amountInserted + 1)) @@ -96,14 +97,14 @@ do then # Delete the rule by its rulenumber # Because changing the action would result in errors - iptables -D $CHAINNAME -s $currentIP -j $ACTION >/dev/null 2>&1 + $IPTABLES_PATH -D $CHAINNAME -s $currentIP -j $ACTION >/dev/null 2>&1 # Increment the counter amountDeleted=$((amountDeleted + 1)) fi -done <<< "`iptables -n -L blocklist-de | awk '{print $4}'`" +done <<< "`$IPTABLES_PATH -n -L blocklist-de | awk '{print $4}'`" ## Print report if [ $PRINT_REPORT -eq 1 ] @@ -124,4 +125,4 @@ fi ## Cleanup # rm -f /tmp/blocklist-ips-unfiltered.txt -rm -f /tmp/blocklist-ips-filtered.txt \ No newline at end of file +rm -f /tmp/blocklist-ips-filtered.txt