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 ;)

11 Responses to “ARD Update DNS Script”

  1. carlo Says:

    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

  2. yamahito Says:

    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?

  3. carlo Says:

    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

  4. SilentBob Says:

    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.

  5. yamahito Says:

    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.

  6. 偷情 Says:

    Its great that you Shed light on a few things I didn’t understand. Thank you , hope you can keep writing blog?2

  7. yamahito Says:

    Evidently not :)

  8. rentacarkosova Says:

    Basically to follow up on the update of this issue on your site and would like to let you know just how much I valued the time you took to put together this handy post. Inside the post, you spoke of how to truly handle this thing with all ease. It would be my personal pleasure to accumulate some more thoughts from your web page and come up to offer others what I discovered from you. Many thanks for your usual excellent effort.

  9. Jared Amodt Says:

    hey, I ran across this site from lycos and look at many of your various other posts. They are cool. Pleasee keep it up!!! Take care,

  10. Zev Eisenberg Says:

    Thank you! This solves a problem that I encounter a few times a day at work. I have a computer at home that I have set to connect to our VPN when it reboots. However, it gets a different IP each time. I’m using DynDNS to broadcast the VPN’s IP address (it’s a 10.x.x.x subnet IP), but ARD doesn’t pick up the change automatically. This fixes it perfectly.

  11. yamahito Says:

    Wow, a genuine comment not from a spam bot!

    I was thinking of taking down this blog; perhaps if some of this stuff is actually still useful I should at least keep an archive up here…

    I’m glad this came in handy, Zev.

Leave a Reply