I have a script which parses a varnish varnishncsa log file. The purpose of the script is that if anyone accesses a certain url on the server, it adds their ip address to iptables to lock them out.
In my script I have a statement which ignores my static office ip address (so that I dont lock myself out of the server).
I am trying to add more ip addresses to exclude them from being locked out, but when I do, it seems to break the script.
#!/bin/bash
for address in `cat /var/log/brute.txt | grep -v -f /var/log/applied_brute.txt`; do
/bin/echo $address >> /var/log/applied_brute.txt
if [ "$address" != "my.of.fi.ce.ip" ]; then
IPTABLE=`echo $address | awk '{ print "/sbin/iptables -A INPUT -s "$0" -j DROP -m state --state NEW,ESTABLISHED,RELATED\n"}'`
fi
echo $IPTABLE
$IPTABLE
done
unset address
unset IPTABLE
What I would like is where the statement
if [ "$address" != "my.of.fi.ce.ip" ]; then
to add a few more ip addresses to it.