1.05.2019

Черный список ip адресов для voip

sh скрипт который

!/bin/bash
BADIPSFILE="badips.list"
BADIPSFILETEMP="$BADIPSFILE".temp
ADDLISTFILE="$BADIPSFILE".load
# get new list
wget https://www.badips.com/get/list/voip/0 -O $BADIPSFILETEMP
# sort new list
sort $BADIPSFILETEMP -o $BADIPSFILETEMP
# touch to be sure that file exist
touch $BADIPSFILE
# diff old ans new file
diff $BADIPSFILE $BADIPSFILETEMP | grep -Po '\d+.\d+.\d+.\d+' > $ADDLISTFILE
# copy new file to old for next ips going fast
cp -f $BADIPSFILETEMP $BADIPSFILE
cp -f drop_temp.xml drop_temp_.xml
BLOCKED_IP=$ADDLISTFILE
IPTABLES="iptables"
if [ -f $BLOCKED_IP ]; then
while read BLOCKED; do
$IPTABLES -A INPUT_direct -i ens192 -s $BLOCKED -p udp -j DROP
done < $BLOCKED_IP
fi