--- rc.parse-isc-dhcpd 2010-02-25 13:36:33.000000000 -0500 +++ rc.parse-isc-dhcpd.new 2010-02-25 13:42:06.000000000 -0500 @@ -3,20 +3,21 @@ # This script will monitor dhcpd.leases and parse # out active leases and ensure they are present # in /var/etc/hosts +SEARCH_DOMAIN=`grep ^domain /etc/resolv.conf | cut -f 2 -d ' '` update_hosts_file() { # $1 = host # $2 = ip cat /var/etc/hosts | grep -v "$1" > /tmp/hosts.tmp if [ "$3" != "" ]; then - echo "$2 $1 # dynamic entry created by rc.parse-isc-dhcpd" >> /tmp/hosts.tmp + echo "$2 $1.$SEARCH_DOMAIN $1 # dynamic entry created by rc.parse-isc-dhcpd" >> /tmp/hosts.tmp fi mv /tmp/hosts.tmp /var/etc/hosts killall -HUP dnsmasq } # Parse file on initial run -cat /var/dhcpd/var/db/dhcpd.leases | grep "lease" -A8 | while read LINE +cat /var/dhcpd/var/db/dhcpd.leases | grep -v "#" | grep ^lease -A8 | while read LINE do HOSTNAMEA=`echo "$LINE" | grep client-hostname | awk '{ print $2 }' | cut -d'"' -f2` ACTIVEA=`echo "$LINE" | grep active` @@ -41,7 +42,7 @@ done # After processed go ahead and tail file looking for changes. -tail -F /var/dhcpd/var/db/dhcpd.leases | grep "lease" -A8 | while read LINE +tail -F /var/dhcpd/var/db/dhcpd.leases | grep -v "#" | grep ^lease -A8 | while read LINE do HOSTNAMEA=`echo "$LINE" | grep client-hostname | awk '{ print $2 }' | cut -d'"' -f2` ACTIVEA=`echo "$LINE" | grep active`