5

I have a problem in our network where our Mac's occasionally get given the wrong machine name while, I guess, getting a new DHCP lease.

The DHCP servers are Windows based - the bulk of our network is Windows, but we have some Linux machines and an increasing number of Macs. The problem specifics is that occasionally a Mac will take on the name of another machine in the network.

For example, I have a new Macbook Pro. In the OSX setup is gets called "gomez", and initially starts up on the network with that name without any problems. But after a few days when the machine was restarted (it had several restarts in the meantime), it ended up being called "florrie", which is actually the name of another machine in another part of the network.

All network ops work fine, and indeed you don't notice most of the time - it's only when you run apps like Perforce that require the hostname that you get problems.

I'm sorry I don't have more info than that, but if I know what to look for I can dig out some more facts. Or any hints on checking the network setup would be useful.

Eric3
  • 302
  • 2
  • 10
Greg Whitfield
  • 181
  • 1
  • 2
  • 5

5 Answers5

6

It's more likely to be a dynamic update DNS issue; Windows clients, beginning with Windows 2000, automatically update Windows DNS servers directly with their new details once they've been leased an IP address by the DHCP server. This way, the DNS and DHCP servers are kept in sync. Macs don't. Previous posters are correct when they say that the Macs are getting these incorrect hostnames from the DNS server. The problem, then, is with the DNS server.

I haven't used the current Microsoft DHCP server but previous versions provided an option specifically for this situation. Instead of the client machine talking directly to the Windows DNS server, as happens automatically with Windows 2000 client and later, the Windows DHCP server can update the Windows DNS server once it has successfully leased an IP address to a client.

You need to enable the option yourself in your Windows DHCP server. The wording for this option will usually be something like "Always Update DNS and Enable Updates To DNS Clients That Do Not Support Dynamic Update".

You might still find this article useful, though it's for Windows Server 2000 DHCP. (I'm not having a good Google day.)

Bahi
  • 91
  • 1
  • 3
3

The answer is here

https://superuser.com/questions/49891/how-can-i-stop-mac-os-x-overriding-my-hostname-when-i-receive-a-dhcp-request-on-s

Copying the better answers here for convenience:


Set it in the Terminal with sudo scutil --set HostName

example: sudo scutil --set HostName server1.mynetwork.com


Depending on how your DHCP is set up, you may be able to use the "DHCP client ID".

  1. System Preferences.
  2. Network
  3. Select your network adapter on the left.
  4. Select "Advanced" button at the bottom.
  5. Set the "DHCP client ID" to your hostname.

If your DHCP server supports it, your hostname will be used for your machine.

3

The Mac is doing a reverse lookup on the DHCP IP it gets to set the hostname. You can either configure the DNS servers to answer correctly as Sam suggests, or you can fix the machine names per-computer.

There are plenty of ways to do this, but the two simplest are:

  1. You can edit /etc/hostconfig and add the line HOSTNAME=[desired hostname] and reboot. This file is deprecated since 10.5, so don't count on it working into Snow Leopard.

  2. In System Preferences -> Sharing you can set the "computer name". If you click the "Edit..." button, you'll see a setting for "Use dynamic global hostname". Untick this to stop the DNS lookup and retain whatever setting you put in there.

Both these ways require setting per-machine, however, so you might prefer to look into sorting the DNS if the number of Macs is going to grow.

  • Thanks for the tips - I'll give a go when back in the office. – Greg Whitfield May 17 '09 at 20:53
  • bonaldi is correct. It's the reverse records that are causing the issue. I've had this same thing happen before to my macs when we moved from bind on unix to bluecat network appliances(don't buy them, they suck) – Tatas Jul 20 '09 at 17:45
2

The problem here is not that the name of your machine is changing, DHCP does not give out machine names, it only distributes IP addresses. However when DHCP allocates an IP, it will record what the name of the machine is that leased the IP. Most DHCP servers will then register that machine in DNS, with that IP. So somewhere along the line, DNS is get the IP and machine name mixed up, or DHCP is registering the wrong details with DNS.

Take a look at your DHCP server and your DNS server and check if the records they have for your machine match up, if they don't, then we need to try and find out why.

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113
  • Thanks - I'll take a look at the DNS during the week. I did think that DHCP only handed out IP addresses, hence my confusion. – Greg Whitfield May 17 '09 at 20:52
0

Greg, it could be a lot of things. What you need to do first is figure out why the Mac is picking the name it displays. Then check the forward and reverse lookups for the IP address and hostname (using nslookup or dig), and your "Computer Name" in the System Preferences.

For a while, this topic had bothered me, so I took did some research and took some notes, and left them here:

Mac OS X - setting the "hostname"

You will probably find that there is some combination of IP address changes + problem with DNS/DHCP integration.

NOTE: This is not a backdoor to advertising for my personal blog... I don't blog. I've left the community wiki flag on, and linking out causes a problem, just copy useful text in here and remove the link.

benc
  • 663
  • 1
  • 5
  • 13