I use a script which I put in my crontab to run every 5 minutes. Here is
the script to those who want it. It saves having to waste Static IP
addresses on abusers of your system.
The script requires the pmwho and pmcomm utilities.
#!/bin/bash
#use fqdn if necessary
pmlist="portmaster1"
#login names allowed to do multiple
#pipe-separated list, for egrep
exempt='name|name2'
log="/var/log/booted"
umask 077
#make sure you have these commands
if [ ! -x /usr/portmaster/pmwho -o ! -x /usr/portmaster/pmcom ]; then
echo portmaster utilities not found
exit 1
fi
# checking and cleaning up workspace
if [ ! -d /tmp/.killer ]; then
rm -r /tmp/.killer
mkdir /tmp/.killer
fi
cd /tmp/.killer
rm -f killme duplicates
# make a separate pmwho file for each portmaster; tail removes two
header lines
for each in $pmlist; do
/usr/portmaster/pmwho $each | tail +3 > $each
done
#combine all, cut down to login name, and check for duplicates. greps
remove garbage
cut -c6-16 portmaster* | grep -v '\- ' | grep -v 'PPP' | grep -Ev
"$exempt" \
| sort | uniq -d > duplicates
for abuser in `cat duplicates`; do
for each in $pmlist; do
grep " $abuser " $each | tr ':' ' ' >> killme
if [ -s killme ]; then
echo ---`date`------------------------------------------- >> $log
while read port user junk;do
/usr/portmaster/pmcom -c $each "reset $port"
echo " $user disconected from $each port $port" >> $log
done < killme
echo >> $log
fi
done
done