Updating your Mac Hostname in DNS

As a Mac user you’re probably noticed that your Mac hostname will change whenever you connect to your corporate network.

Even though you named your Mac “LancesRetinaBadBoy”, when you open a terminal it says the name is “PC-Backup47”.

What’s that all about?  🙁

Here’s the whole story:

Whenever the mac joins to the network it gets an IP address from the DHCP server.

When the address is assigned to your Mac, the DNS server is supposed to be updated with the name of your machine.

The Mac is supposed to update the DNS to associate it’s name with that IP address. This is something that Windows does correctly.

The Mac fails at this and instead picks up the name previously assigned to that IP address

A long time ago we added a fix to DirectControl for the Mac to take care of this.  Whenever the network changes on the Mac, we will attempt to update DNS with the proper hostname.

We also added this as a command line option. You can run it by typing:
>addns -U

It will update the DNS with the correct value whenever the network state changes.

You can learn more about the “addns” command by typing:
>man addns

If it fails to update the DNS then you will see a number of error messages. You can read through the messages to see what is happening.

Try it and see the output in your environment.

If it’s constantly failing, you might want to make sure the “Allow Dynamic DNS Updates” is set in your DNS.

Screen Shot 2012-08-23 at 4.41.34 PM.png

Try turning this on in your WIndows DNS too:

Screen Shot 2012-08-23 at 4.36.23 PM.png