Crie o arquivo /etc/iptables/blocked.ips com a lista de IPs ou redes a serem bloqueados.
Como exemplo
192.168.0.0/24 200.122.53.11 74.67.1.213
E o script que será o responsável por carregar as regras.
#!/bin/bash IPT=`which iptables` SPAMLIST="spamlist" SPAMDROPMSG="SPAM LIST DROP" BADIPS=$(egrep -v -E "^#|^$" /etc/iptables/blocked.ips) # 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

Join the conversation