Код:
#!/usr/local/bin/bash
# (c) 2009, Andrey Zentavr
# To use this software, please install port from /usr/ports/net-mgmt/dhcdrop
# Or download port tarball from http://www.freebsd.org/cgi/cvsweb.cgi/ports/net-mgmt/dhcdrop/dhcdrop.tar.gz?tarball=1
# and unpack it into /usr/ports/net-mgmt/dhcdrop
# Legal DHCP Serverz, space separated mac address
LEGAL_SERVERS="00:15:17:b8:f9:1e 00:15:17:b8:f9:1f 00:1b:21:21:83:d5"
# gw1:em0+vlan*** gw1:em1 nodeny:em0
DROPPER="/usr/local/sbin/dhcdrop"
IFNAME="em0 vlan10 vlan30" # Interfaces on our Router, space separated
PARAMS="-t -m 3"
# Lets Go!
# legal params
for mac in ${LEGAL_SERVERS}; do
LMAC="${LMAC} -l ${mac}"
done
#echo ${LMAC}
# Discovering on every interface
for IF in ${IFNAME}; do
echo "Processing interface ${IF}"
# test to any DHCP-Server
${DROPPER} -i ${IF} ${LMAC} ${PARAMS}
# Check for status 200
if [ $? = 200 ]; then
echo "Illegal server found on ${IF}! Dropping him!"
${DROPPER} -i ${IF} ${LMAC} -y
else
echo "Illegal server not found on ${IF}."
fi
done
echo "All done"