Help with Dynamic DNS on Xserve and OSX clients
We have a need for Dynamic DNS updates on our network. All our windows clients do this via the DNS configuration on XP. We tell each machine to register it's hostname with the DNS server whether it is DHCP or STATIC.
This allows our network monitoring and mapping systems to resolve the hostnames of each machine.
90% of our machines are Mac and we need them to resolve as well.
I was given a script to do this but each attempt to make it work resulted in all my dns zones and entries being deleted from the DNS server. All our clients are 10.4.10. We run the latest Xserve as well.
Here is the script I received with generic info. It needs to be tweeked for individual site usage.
Create the below script in /S/L/SystemConfiguration/Kicker.Bundles/C/Resources that is executed every time Kicker runs the set-hostname script (with a tweak to the Kicker.xml file).
#!/bin/sh
#
# update_dns
#
primary=$(netstat -rn | sed -n 's/default [ ]*[^ ]*[ ]*[^ ]*[ ]*[^ ]*[ ]*[^ ]*[ ]*\([^ ]*\)[ ]*[^ ]*/\1/p')
if [ "${primary}" = "" ]; then
logger -i -p daemon.notice -t update_dns "Unable to determine the primary network interface"
fi
ip_address=$(ifconfig ${primary} inet 2>/dev/null | sed -n '/169\.254/d;/127\.0\.0\.1/d;/0\.0\.0\.0/d;s/^.*inet \([0-9\.]*\) netmask.*/\1/p')
if [ "${ip_address}" = "" ] ; then
logger -i -p daemon.notice -t update_dns "Unable to determine the IP address of the ${primary} interface"
fi
# Update the DNS record if the IP address has changed
host=$(hostname)
old_ip=$(/usr/bin/host $host 2>/dev/null | awk '{print $NF}')
if [ "${old_ip}" = "${ip_address}" ] ; then
logger -i -p daemon.notice -t update_dns "Skipping DNS update, IP hasn't changed"
exit 0
fi
logger -i -p daemon.notice -t update_dns "Updating the DNS record(s) to indicate IP address: ${ip_address}"
KEY=/etc/Kmyhost.example.com.+157+40645.key
cat