#!/bin/bash
IPCHAINS=/sbin/ipchains

#
# Pleople with a high hit rate might want to limit the size of the
# block chain to avoid slowing down their IP stack too much.
#
# This will construct a LRU method - uncomment if you want that.
#
# MAXENTRIES=500
# NUMENTRIES=$($IPCHAINS -nL block | wc -l)
# # note that this gives the real number of entries+2 (or +3 if an unblocking
# # rule is in effect)
#
#if [ $NUMENTRIES -gt $MAXENTRIES ] ; then  
#        ipchains -D block 1     # use 2 here if you have an unblocking rule
#                                # at position 1 !
#fi

$IPCHAINS -nL block | grep -q "$1" || {
	$IPCHAINS -A block -s "$1" -j DENY
	# Play sound
	#/usr/local/bin/bcastabsnd blocking
}
