วิธี Block spam ด้วย Iptables

rm -rf /root/spamhaus.sh
nano /root/spamhaus.sh
chmod 777 /root/spamhaus.sh
./root/spamhaus.sh

crontab -e

0 3 * * * /root/spamhaus.sh

 

service stop
rm -rf /mnt/iptables
wget –no-check-certificate https://myip.ms/files/blacklist/csf/latest_blacklist.txt -O /mnt/iptables
=/sbin/iptables
SPAMLIST=”spamlist”
SPAMDROPMSG=”SPAM LIST DROP”
BADIPS=$(egrep -v -E “^#|^$” /mnt/iptables)
# create a new iptables list
$IPT -N $SPAMLIST
for ipblock in $BADIPS
do
$IPT -A $SPAMLIST -s $ipblock -j LOG –log-prefix “$SPAMDROPMSG”
$IPT -A $SPAMLIST -s $ipblock -j DROP
done
$IPT -I INPUT -j $SPAMLIST
$IPT -I OUTPUT -j $SPAMLIST
$IPT -I FORWARD -j $SPAMLIST