#!/bin/bash if [ ! -e /var/log/wirefall ] then touch /var/log/wirefall fi if [ "$2" == "on" ] then check APPEND="-A" INSERT="-I" echo $1 >> /var/log/wirefall elif [ "$2" == "off" ] then check APPEND="-D" INSERT="-D" cat /var/log/wirefall | grep -v $1 > /var/log/delete && mv /var/log/delete /var/log/wirefall else echo "Error: \"off\" or \"on\" expected as second argument" exit 1 fi function check() { info=`cat /var/log/wirefall | grep ^${1}` if [ "$info" != "" ] then echo "Error: \"$1\" already blocked/unlocked" exit 1 fi } #iptables $INSERT INPUT -s $1 -j DROP #iptables $INSERT OUTPUT -d $1 -j DROP #iptables $INSERT FORWARD -d $1 -j DROP #echo "IP \"${1}\" drop ${2}." exit 0