Ensure Macs get correct machine name from DHCP?
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.
Solution 1:
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.)
Solution 2:
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:
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.
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.
Solution 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".
- System Preferences.
- Network
- Select your network adapter on the left.
- Select "Advanced" button at the bottom.
- Set the "DHCP client ID" to your hostname.
If your DHCP server supports it, your hostname will be used for your machine.
Solution 4:
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.