Block them!

Get the spammers addresses and create a ready-to-import script.

for IPTables:

#IPTABLES

saveTo=<directorty>
now =$(date);
echo -e "#!/bin/bash" > $saveTo/iptables.out
echo "#Rules generated on $now" > $saveTo/iptables.out
echo -e "/sbin/iptables -N BLOCKIPS" >> $saveTo/iptables.out
echo -e "/sbin/iptables -F BLOCKIPS" >> $saveTo/iptables.out
echo -e "BLOCK_LIST=\"" >> $saveTo/iptables.out
wget -q -O - http://feeds.dshield.org/block.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0\t/ { print $1;}'>> $saveTo/iptables.out

wget -q -O - http://www.spamhaus.org/drop/drop.txt | awk --posix '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\// { print $1;}' >> $saveTo/iptables.out

wget -q -O - http://www.spamhaus.org/drop/edrop.txt | awk --posix '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\// { print $1;}' >> $saveTo/iptables.out

wget -q -O - http://www.openbl.org/lists/base_7days.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print $1;}' >> $saveTo/iptables.out

echo -e "\"" >> $saveTo/iptables.out

echo -e "for IP in \$BLOCK_LIST\ndo\n/sbin/iptables -A BLOCKIPS -s \$IP -j DROP\ndone" >> $saveTo/iptables.out

echo -e "/sbin/iptables -A BLOCKIPS -j RETURN" >> $saveTo/iptables.out

For mikrotik:

saveTo=<directory>
now=$(date);

#MICROTIK

echo "#Rules generated on $now" > $saveTo/microtik.rsc
echo "/ip firewall address-list" >> $saveTo/microtik.rsc
wget -q -O - http://feeds.dshield.org/block.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0\t/ { print "add list=blacklist address=" $1 "/24 comment=blacklist-import";}' >> $saveTo/microtik.rsc

wget -q -O - http://www.spamhaus.org/drop/drop.txt | awk --posix '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\// { print "add list=blacklist address=" $1 " comment=blacklist-import";}' >> $saveTo/microtik.rsc

wget -q -O - http://www.spamhaus.org/drop/edrop.txt | awk --posix '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\// { print "add list=blacklist address=" $1 " comment=blacklist-import";}' >> $saveTo/microtik.rsc

wget -q -O - http://www.openbl.org/lists/base_7days.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist-import";}' >> $saveTo/microtik.rsc

For automation, and source, check: http://joshaven.com/resources/tricks/mikrotik-automatically-updated-address-list/

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.