From 91e840746afa7c73c626c7e801cac19bc4e1d873 Mon Sep 17 00:00:00 2001 From: bisco Date: Mon, 4 Mar 2019 21:49:26 +0100 Subject: [PATCH] block_range.sh: removed wget's output; added '-exist' option to ipset command to ignore errors when same set already exists --- block_range.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block_range.sh b/block_range.sh index c2724ed..8325df3 100644 --- a/block_range.sh +++ b/block_range.sh @@ -7,7 +7,7 @@ set -e ### Variables URL="http://www.ipdeny.com/ipblocks/data/countries" -ZONES="cn hk ru tw" +ZONES="cn hk ru tw kp kr sg" SCRIPTDIR="/root/firewall" ZONEDIR="${SCRIPTDIR}/blocked_zones/" RULESFILE="/tmp/iptables_rules-$(date +'%s')" @@ -93,7 +93,7 @@ download_zones() for zone in $(echo "${ZONES[*]}"); do echo "Downloading $zone.zone file"; - ${WGET} -P "${ZONEDIR}" "${URL}/$zone.zone"; + ${WGET} --quiet -P "${ZONEDIR}" "${URL}/$zone.zone"; done } @@ -105,7 +105,7 @@ create_chains() for chain in $(echo "${ZONES[*]}"); do echo "Creating $chain chain"; - ${IPSET} create ${chain} hash:net; + ${IPSET} create -exist ${chain} hash:net; done } @@ -116,9 +116,10 @@ populate_chains() { for chain in $(echo "${ZONES[*]}"); do + echo "Populating $chain"; for ip in $(cat $ZONEDIR/$chain.zone); do - ${IPSET} add $chain $ip; + ${IPSET} add -exist $chain $ip; done; done }