#!/bin/bash SPOOLDIR=/var/spool/firewall/ FWSCRIPT=/usr/local/antispam/maillogalyser/firewall.script mkdir $SPOOLDIR &> /dev/null cd $SPOOLDIR ls -l echo First purging any records out of time for file in `find ./* -maxdepth 0 -mmin +60` do echo Purging $file rm -f $file done echo "#!/bin/bash" > $FWSCRIPT echo -n "# Antispam firewall script created " >> $FWSCRIPT date >> $FWSCRIPT echo "/sbin/ipchains -F input" >> $FWSCRIPT echo Then creating firewall script for ip in `ls $SPOOLDIR` do echo "/sbin/ipchains -A input -s $ip -d 0.0.0.0/0.0.0.0 25:25 -p 6 -j DENY" >> $FWSCRIPT done chmod +x $FWSCRIPT echo And the final firewall script looks like this ... cat $FWSCRIPT echo And running that script now ... $FWSCRIPT echo And the the final firwall looks like this now ... #/sbin/ipchains-save