31 lines
651 B
Bash
31 lines
651 B
Bash
#!/bin/bash
|
|
# Purpose: Block all traffic from conrtys in ISO var. Use ISO code.
|
|
# -------------------------------------------------------------------------------
|
|
|
|
### Setting VAR's ###
|
|
ISO="ru cn br"
|
|
|
|
WGET=/usr/bin/wget
|
|
EGREP=/bin/egrep
|
|
SPAMLIST="countrydrop"
|
|
ZONEROOT="/opt/blockfiles"
|
|
DLROOT="http://www.ipdeny.com/ipblocks/data/countries"
|
|
|
|
#running script
|
|
[ ! -d $ZONEROOT ] && /bin/mkdir -p $ZONEROOT
|
|
rm /etc/nginx/blockips.conf
|
|
|
|
for c in $ISO
|
|
do
|
|
tDB=$ZONEROOT/$c.zone
|
|
$WGET -O $tDB $DLROOT/$c.zone
|
|
BADIPS=$(egrep -v "^#|^$" $tDB)
|
|
|
|
for ipblock in $BADIPS
|
|
do
|
|
echo "deny $ipblock" >> /etc/nginx/blockips.conf
|
|
done
|
|
|
|
done
|
|
exit 0
|