#!/bin/bash info=`cat /var/log/wirefall | grep "$1"` if [ "$info" != "" ] then exist="yes" else exist="no" fi if [ ! -e /var/log/wirefall ] then touch /var/log/wirefall fi if [ "$2" == "on" ] then if [ "$exist" = "yes" ] then echo "Error: $1 already blocked" exit 1 else APPEND="-A" INSERT="-I" echo $1 >> /var/log/wirefall echo "$1 locked" fi elif [ "$2" == "off" ] then info=`cat /var/log/wirefall | grep "$1"` if [ "$exist" = "no" ] then echo "Error: $1 not locked" exit 1 else APPEND="-D" INSERT="-D" touch /var/log/delete cat /var/log/wirefall | grep -v $1 > /var/log/delete mv /var/log/delete /var/log/wirefall echo "$1 unlocked" fi else echo "Usage: IP " echo "\"on\" or \"off\" are expected as second argument" 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