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
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!!!!!!
