How does a Mac decide its name on the network?

Hi,


How does a Mac (a MacBook Pro running macOS High Sierra, for instance) decide its own name on a local network? How can I configure this?


What I mean by "its own name" is, to be exact, the DNS name that it suggests to other computers in order to connect to services it provides via the Sharing pane in System Preferences. For instance, right now, if I turn on Remote Login from the Sharing pane, then my mac tells me "To log in to this computer remotely, type "ssh alexis@sydneys-mbp.localdomain". So this Mac thinks it can be reached at the DNS name "sydneys-mbp.localdomain". We might call this the sharing name. Where does it get this name from?


The reason I ask is that this machine is not Sydney's MBP (although it used to be) and, as near as I can tell, I have set every possible configuration that could be used on the machine to remove that name. Here are things I have already tried:


1. In the Sharing pane, I have already set the Computer Name to "DesertMac", and indeed the system tells me that "Computers on your local network can access your computer at: DesertMac.local."


2. I have already used the system configuration command line utility, scutil, in order to set the ComputerName, the HostName, and the LocalHostName to DesertMac as well. (You do this by performing commands like: "scutil --set ComputerName DesertMac").


3. I have already used the "defaults" command to set the preferred NetBIOS name. (You do this with commands like: "sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string DesertMac")


Despite all these measures, as soon as my system joins the network, the sharing name is quickly set to the old, incorrect name, as is the the NetBIOS name. (I see the NetBIOS name in System Preferences / Network / Advanced / WINS, or by doing "echo 'show State:/Network/NetBIOS' | scutil".)


Because the incorrect sharing name also appears as the NetBIOS name, this makes me wonder if the Mac's NetBIOS stack is responsible for remembering this name or accepting it from some external computer that acts as a name assigner, but I don't understand how that would work. Because the incorrect name ("sydneys-mbp") appears with the DNS suffix which is the router's search domain (".localdomain") this alternatively makes me wonder if the router is responsible, but I also don't understand how that would work. When I watch the system console logs via Console.app, I can see that the "digest-service" process is registering or effecting the change, but I don't know what this means.


So, to recap, this all raises two main questions:


1. How does a Mac decide what its own DNS name is?


Does it remember what it used to be, in some obscure cache or setting that I need to reset? This seems hard to believe because I've tried resetting everything imaginable.


Does it receive an assignment from some external name assigner server, like the router? This seems like what must be happening. But it is puzzling, because the only mechanisms I can imagine are the router's DHCP server and DNS name server. I thought that DHCP only allowed the server to assign a numerical address to the Mac, and that DNS only allowed the Mac to lookup a specific name. So I was under the impression (maybe wrong?) that neither of those technologies could be used to assign a name to the Mac. Or could there be another technology, like a NetBIOS, which can act as a name assigner and force a Mac to accept a name? And how would any of these technologies choose the name to begin with?


2. How do I configure a Mac to tell the world it wants to be known by a different name?


Setting the ComputerName is clearly not enough. This does affect my Mac's Bonjour name (i.e., "DesertMac.local.") but it does not seem to affect its non-Bonjour DNS name (i.e., "sydneys-mbp.localdomain."). Is there something else I can tell the Mac that will hint to the (hypothetical) name assigner on the network that the Mac wants to be known differently? Or do I need to reconfigure the (hypothetical) name assigner manually?


I'd really appreciate any help on this. For what it's worth, a see a trail of dozens of similar questions dating back on these forums for many years. They usually take the form of people complaining that they can't control the Mac's NetBIOS name, and people giving advice to update the ComputerName, advice which does not work for me. Also, for what it's worth, the router on my network is a Ubiquiti UniFi Security Gateway, and I can modify its configurations if need be. But I don't see anything in its configurations now which mentions these outdated, incorrect names.

MacBook Pro (15-inch, Late 2016), macOS High Sierra (10.13.6)

Posted on Aug 24, 2018 9:04 AM

Reply

Similar questions

5 replies

Aug 24, 2018 4:25 PM in response to algal

On the same network segment (e.g. 192.168.3) all Macs address each other as hostname.local. This is mentioned in System Preferences : Sharing : Computer Name. If you are using VPN as I am right now, the computername will be whatever the remove DNS server assigns. I can still get my local computer name using:


$ networksetup -getcomputername


which is what is in my ~/.bashrc to always set my PS1 Terminal prompt to the correct name.

Aug 24, 2018 9:21 AM in response to algal

How does a Mac (a MacBook Pro running macOS High Sierra, for instance) decide its own name on a local network? How can I configure this?


you can change the name if you have admin control over your Router—log in change the name


Depending on the type of router you have. From the browser window try: http://192.168.1.1/


Apple Airport router:

How to change name of wi-fi network?

Aug 25, 2018 3:38 PM in response to algal

Thanks to more investigation and the help here I have figured it out and thought I’d share what I learned since it may help someone.


1. How does a Mac decide what its own DNS name is?


Does it remember what it used to be, in some obscure cache or setting that I need to reset?


No.


Does it receive an assignment from some external name assigner server, like the router?



Yes! It gets it from the router’s DHCP server. I thought DHCP was only for assigning numerical IP addresses but I believe it was wrong. It can also assign a name to a client, as well as telling the client where to find the name servers the client should use to lookup the numerical addresses for names.


Or could there be another technology, like a NetBIOS, which can act as a name assigner and force a Mac to accept a name?


I still don’t know anything about NetBIOS (yay!) but as near as I can tell it is was a symptom, not a cause, of the forcibly assigned DNS name.


And how would any of these technologies choose the name to begin with?


This is the solution to the problem. I believe what happened was:

1. Earlier, the device was configured with OldName.

2. It told the router its hostname was OldName (probably through DHCP?)

3. The router remembered an association between OldName, the device’s MAC address, and the IP address the router assigns to the device

4. The router henceforth assigned the device the name OldName via DHCP, and reported that association via its own DNS to every other device on the network. This is why the Sharing pane was quite accurately reporting that OldName was the best one to use for other devices to connect to this device’s services.

5. The device was locally re-configured to be named NewName

6. But, as soon as the device connects to the network, the assigned name a OldName overrides the locally configured NewName for sharing, because it’s still the name that everyone on the network using that DNS server will see the device at.


So this leads to one takeaway of this story. The router is not very good because it’s smart enough to listen and remember what a device wants to be called, but then not smart enough to update its records when the device changes what it wants to be called.


2. How do I configure a Mac to tell the world it wants to be known by a different name?


All the mechanisms I already described in my original question work fine but not in this situation because the server was ignoring the device’s update preferences, so the reality is that other devices using that routerks DNS would find it at the old name.


This leads to my second takesway. macOS offers inadequate logging and diagnostics here, because it lets you configure what you want a device to be called, and then lets the server override that name for sharing purposes via DHCP, but it provides no logging at alll to indicate this is happening and no way to cancel that override.


My solution was finally just to configure the router not to listen to clients’ preferred hostnames. If it never listens to them, it never holds onto outdated names and forces them onto clients.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How does a Mac decide its name on the network?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.