Shell Script to Block the IP addresses
by krishnapa from LinuxQuestions.org on (#4XCWX)
Hi All,
I have created shell script to block the IP addresses in 4 servers.
============================================================
#!/bin/sh
LOG=/home/logs/ip.log
. /home/server.conf
for n in ${HOSTS}
do
ssh -q -A -i /home/.ssh/id_home $n "/sbin/iptables -I INPUT -s $LOG -j DROP"
done
============================================================
Where
vi /home/server.conf (contain all the 4 host server IP addresses)
HOSTS="10.40.11.1 10.40.11.2 10.40.11.3 10.40.11.4"
LOG=/home/logs/ip.log contain all 2 IP addresses that I needs to block in iptables of above 4 servers
say-
11.22.33.44
11.22.33.55
Thanks,


I have created shell script to block the IP addresses in 4 servers.
============================================================
#!/bin/sh
LOG=/home/logs/ip.log
. /home/server.conf
for n in ${HOSTS}
do
ssh -q -A -i /home/.ssh/id_home $n "/sbin/iptables -I INPUT -s $LOG -j DROP"
done
============================================================
Where
vi /home/server.conf (contain all the 4 host server IP addresses)
HOSTS="10.40.11.1 10.40.11.2 10.40.11.3 10.40.11.4"
LOG=/home/logs/ip.log contain all 2 IP addresses that I needs to block in iptables of above 4 servers
say-
11.22.33.44
11.22.33.55
Thanks,