How to prevent machine from renaming itself at start up

bonjourNetwork

My iMac's name is windowlick. Every time I reboot it, for some reason it detects that the name windowlick is already in use on the network and renames itself with a random suffix, e.g. windowlick (3829) or the like, and it gets a zeroconf/bonjour hostname of windowlick-2.local instead of the usual windowlick.local.

I can manually fix this by going to the Sharing preferences panel, but I'd rather not have to do this, especially since I often do remote access from an external network (via ssh to another machine that gets the incoming port assignment) and if my machine rebooted due to a power failure or a system update I don't like having to guess at the hostname.

My computer gets its IP address via DHCP assignment from the router (a recent Netgear); it also behaved this way on my previous router (an Apple Time Capsule). It has a reserved IP address for its wired Ethernet port, but it connects via both Ethernet and Wi-Fi (which does not have an address reservation). I suspect that something to do with name assignment is doing something weird with the order of operations on the Wi-Fi vs. Ethernet interfaces.

Unfortunately, I cannot simply disable Wi-Fi, as I make use of OS features that require that my Wi-Fi be active (for example, Unlock with Apple Watch).

Is there any way to tell macOS to not be "polite" and rename itself if it sees "another" machine by the same name?

This seems similar to My Mac mini's computer name keeps changing when it resumes from sleep but I don't have the problem when resuming from sleep, it's only after a reboot, and I already have the static IP assignment per the accepted answer on that question. Also, this doesn't happen on my MacBook (which does not have a static assignment).

Best Answer

For what it's worth, I had this exact same problem and also need to have both wifi and ethernet enabled on my iMac. It started after upgrading to Mojave, my router is an Asus RT-AC88U and had until Mojave been fine. After the update I started getting the message in macOS about a duplicate computer name on my network and my computer changed it's name from "iMac" to "iMac (2)" - but within a few days is was up to "iMac (2000)" and kept rising.

Spoke to Apple, they suggested deleting the wifi adapter and re-adding it in Mojave which didn't fix it. The only other thing they suggested was a rebuild of macOS from scratch.

I tried all the other fixes suggested everywhere, disabling wifi (not good as I also want to be able to unlock my mac with my apple watch) - but the problem does go away, renaming network locations, rebooting router, delete and re-add ethernet and everything else I came across. I also had the smart wifi option enabled on the router to combine the 2.4G and 5G SSID in to a single name broadcast (the router then assigns devices to the correct band) - it was suggested this might also be a problem so I put the router back to 2 different SSID's for the different bands. Nothing fixed the issue.

Then I realised that my ethernet adapter had a fixed IP address that I gave it but the wifi adapter was on DHCP. I had also reserved the fixed IP address on the router for ethernet but not wifi. So I reserved the 2 addresses I wanted for both adapters on the router and then set them to DHCP on the iMac. I also made sure that the Advanced settings for the IP address had a different DHCP Client ID name specified just to be sure.

So far so good, the iMac hasn't changed it's name in a few days now.

Related Question