ARD Update DNS Script
Well, no luck on the apple forums, so I’ve resorted to working around the problem I talked about yesterday.
here it is: it’s a script that looks at each computer in an ARD computer list, looks up the DNS entry using an IP address (in bash, which gets the right DNS name for me), and updates the ARD entry for DNS name.
tell application "Remote Desktop" set ComputerList to computer in computer list "Update DNS names" repeat with x in ComputerList --get DNS Name (using unix script) set y to Internet address of x as string set GetDNS to (text 1 thru -2 of (do shell script "host " & y & " | cut -f 5 -d ' '")) --log GetDNS --set DNS Name set DNS name of x to GetDNS --move from ComputerList to SynchNames --add x to computer list "SynchNames" remove x from computer list "Update DNS names" end repeat end tell
Nice and simple. I have another renaming script that I want to run on it, so I have it moved to another computer list that’s associated with my renaming script.
Well, I hope that helps someone
May 4th, 2007 at 9:07 am
Hi, I have tried your script. Thehe Macs now bear a weird 3NXDOMAIN DNS name in ARD.
What might be the reason? WIndows PCs and server do show up their DNS properly….
Thanks!
Carlo
May 4th, 2007 at 9:26 am
Hi Carlo:
How does the domain that ARD shows compare with what you get when you do a reverse DNS lookup on the IP address?
May 4th, 2007 at 10:27 am
Hi this is the nslookup of the IP
Carlo:~ carlo$ nslookup 10.70.65.50
Server: 10.70.64.90
Address: 10.70.64.90#53
** server can’t find 50.65.70.10.in-addr.arpa: NXDOMAIN
Many thanks!
Ciao
May 4th, 2007 at 10:56 am
It appears that the script always expects a valid response, but if the reverse DNS lookup doesn’t resolve to a hostname it comes back with an error message, and the DNS name is updated to the 6th word (as the script uses cut with a delimiter of a space), which will presumably be the same for every host that doesn’t resolve.
Some error catching should be added to the script, such as checking that the response doesn’t contain the string (or words) “server can’t find” so that it only updates the entry if it’s valid.
It might not look pretty, but I don’t think it breaks anything.
May 4th, 2007 at 12:11 pm
Hm, it looks to me like that’s a private address range (which is why the server can’t find any DNS entries for your machines).
As SilentBob says, the script will only ever be as good as the value the command “host [username]” returns. It’s only a quick and dirty fix, though, so I think any error checking isn’t really worth the time it’ll take to put it in: you know when something goes wrong, and that’s good enough for me.
You’ll need to speak to your network manager to sort out whether or not your machines need/can have DNS names.