block_range.sh: removed wget's output; added '-exist' option to ipset command to ignore errors when same set already exists

This commit is contained in:
bisco 2019-03-04 21:49:26 +01:00
parent fa5c044f39
commit 91e840746a
1 changed files with 5 additions and 4 deletions

View File

@ -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
}