Home » block-multiple-IPs-iptables

block-multiple-IPs-iptables

First of all create the file with named as below

#vi ip.blocked

then put the ips in ip.blocked as
192.168.0.1
216.288.55.147
Etc…
Then create file block and paste the below shell script.

BLOCKDB=”ip.blocked”
IPS=$(grep -Ev “^#” $BLOCKDB)
for i in $IPS
do
iptables -A INPUT -s $i -j DROP
iptables -A OUTPUT -d $i -j DROP
done

then press x! to save file
And we need to chmod execution for block file.

#chmod +x block

And run

#./block

After that save iptables

#service iptables save

Enjoy!!!!!!

Leave a Reply

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

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud