Can we view or edit HostName value via macOS desktop UI?

Here are two instances where I found that setting the computer name via System Preferences > Sharing > Computer Name does not really set the HostName attribute.

The macOS version is macOS High Sierra version 10.13.6 in both instances below.

Instance 1

I got a brand new MacBook Pro which had the following settings under System Preferences > Sharing.

  • Computer Name: Lone's MacBook Pro
  • Local Hostname: Lones-MacBook-Pro.local

The scutil and hostname output looked like this:

$ scutil --get ComputerName
Lone's MacBook Pro
$ scutil --get LocalHostName
Lones-MacBook-Pro
$ scutil --get HostName
HostName: not set
$ hostname
Lones-MacBook-Pro.local

Then I went to System Preferences > Sharing and set the Computer Name to luke. Now the output looked like this:

$ scutil --get ComputerName
luke
$ scutil --get LocalHostName
luke
$ scutil --get HostName
HostName: not set
$ hostname
luke.local

The HostName attribute is not set!

Instance 2

I was working on a friend's MacBook Pro who had some other HostName already set (perhaps someone else had configured it for him). He had the following settings under System Preferences > Sharing.

  • Computer Name: mmod
  • Local Hostname: mmod.local

The CLI output looked like this:

$ scutil --get ComputerName
mmod
$ scutil --get LocalHostName
mmod
$ scutil --get HostName
mmod
$ hostname
mmod

Now I went to System Preferences > Sharing and set Computer Name to luke. The output now is:

$ scutil --get ComputerName
luke
$ scutil --get LocalHostName
luke
$ scutil --get HostName
mmod
$ hostname
mmod

Again, HostName remains unaffected.

Question

I know that I can set the HostName attribute with the scutil --set HostName luke command.

My question is: Is there a macOS desktop UI element where I can view or edit this HostName attribute without having to run CLI commands?


There's no place in the GUI to change it, because it's typically set by an external source.

Your hostname is determined by the following (in order):

  • name supplied by DHCP/BOOTP server
  • name returned by a reverse DNS lookup
  • the localhost name (what was used to set LocalHostName value)
  • name acutal name localhost

Most routers now have the ability to "register" the DHCP lease in the DNS resolver cache. So, what's happening is this...

At some point, your Mac didn't exist as a DHCP mapping or DNS entry on your router. When it connected, it sent a request which included it's preferred hostname along with a request for an address. That preferred hostname defaulted to your LocalHostName as the first two conditions would have returned nothing. When you got the address, it "registered" that hostname with an IP.

Now, you want to change the name, but it keeps coming back to the original host - this is because the router now "knows" your machine has having that name and will overwrite it per DNS (which takes priority).

TL;DR

That name is coming from your DHCP Server and/or DNS chache. If you want to clear that out and set a new one, you'll have to do it at the router.