The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,858 other subscribers

I really dislike MacOS choosing machine names, and having the long machine names and short hostnames in separate places to change (one of them command-line only)

Posted by jpluimers on 2024/12/05

After installing my Apple Silicon MacBook, I found out my machine had gotten named automatically in two different ways:

  1. readable name Jeroen’s Macbook Pro
  2. full name Jeroens-MacBook-Pro
  3. local hostname Jeroens-MacBook-Pro.local
  4. actual hostname Jeroens-MBP
  5. HostName from scutil

A few reasons I dislike that:

  • Having 5 different names for the same machine creates a mess
  • They chose for me where I like to choose myself
  • They use spaces, quotes and hyphens where I like single a complete word
  • They use mixed case where I like single case (preferably lower case) as not all other computers handle mixed case well

Finding out how to fix all this was a tedious job as I had to keep refining queries:

The results from these queries that actually helped me further:

  • [Wayback/Archive] Change your computer’s name or local hostname on Mac – Apple Support (UK) which helped me change 1. and 2.:

    Change your computer’s name

    You can view and change your computer’s name in the About settings window.

    1. On your Mac, choose Apple menu  > System Settings, click General ⚙ in the sidebar, then click About on the right. (You may need to scroll down.)
    2. Type a new name in the Name field.

    This is confusing as the field does not look like it can be edited “in place”: a grey background like the other fields (which all are read-only), and just slightly bit darker text than the read-only fields.

    Change your computer’s local hostname

    The local hostname is your computer’s name with .local added, and any spaces are replaced with hyphens. For example, if your computer’s name is My Computer, your local hostname is My-Computer.local. Local hostnames aren’t case sensitive, so my-computer.local is the same as My-Computer.local.

    1. On your Mac, choose Apple menu  > System Settings, click General ⚙ in the sidebar, then click Sharing on the right. (You may need to scroll down.)Open Sharing settings for me
    2. Click Edit in the “Local hostname” section at the bottom of the window, then enter a new local hostname.
    3. If needed, turn on the Use dynamic global hostname option. See Use a dynamic global hostname.
    4. Click OK.

    This second setting at least has a decent “Edit…” button so it is clear that you can change it at all.

  • [Wayback/Archive] network – Set the hostname/computer name for macOS – Ask Different which in the first answer failed to mention or fully quote the actual source (see below) in the answer, but had this useful comment:

    sudo hostname <new-host-name> also sets hostname that can be used from terminal. It would be nice to see what is the difference and relations between these internal hostnames in MacOS and standard *nix hostnames (as @scrpy asked). Additionally, System Preferences -> Sharing is another place to change some hostname, so again, what is the diff to previous hostname settings?

    The second answer was more complete (restarting the Mac is needed because some software does not update itself automatically from the new hostnames):

    You need to set the hostname in two places

    1. System Settings -> General -> About -> Name
    2. In a terminal, sudo scutil --set HostName <new host name>
    You can verify the hostname is correctly updated by doing:
    scutil --get HostName 
    scutil --get LocalHostName 
    scutil --get ComputerName
    
    Then, dscacheutil -flushcache and restart your mac.

    The source of the first answer:

    [Wayback/Archive] How to set the Mac hostname or computer name from the terminal

    Issue:

    The hostname present in the Mac System Preferences is different to the one shown in the terminal.

    The following error may also be seen:

    Network License Error -96.7.1100

    Environment:

    macOS X

    Solution:

    This information can be useful when configuring your workstation remotely through ssh, or when you need to change the fully qualified hostname of the workstation (which can’t be done from the UI).
    Note: The following procedure is for informational purposes only and is not an Autodesk certified or supported workflow. Should issues arise with this procedure, they will not be addressed by Autodesk Customer Support.
    Perform the following tasks to change the workstation hostname using the scutil command.
    1. Open a terminal.
    2. Type the following command to change the primary hostname of your Mac:
      This is your fully qualified hostname, for example myMac.domain.com
    sudo scutil --set HostName <new host name>
    So for example:
    sudo scutil --set HostName flame01.domain.com
    1. Type the following command to change the Bonjour hostname of your Mac:
      This is the name usable on the local network, for example myMac.local.
    sudo scutil --set LocalHostName <new host name>
    So for example:
    sudo scutil --set LocalHostName flame01
    1. Type the following command to change the computer name:
      This is the user-friendly computer name you see in Finder, for example myMac.
    sudo scutil --set ComputerName <new name>
    So for example:
    sudo scutil --set ComputerName flame01
    
    1. Flush the DNS cache by typing:
      dscacheutil -flushcache
    2. Restart Mac.

    From that, I deduced these:

    scutil --get HostName ; scutil --get HostName ; scutil --get HostName ; hostname; scutil --get LocalHostName ;aaaaa

    This gets them in the order 1., 2., 4,. 5. where 4. actually returned it with the suffix set by the router: Jeroens-MBP.fritz.box (this is still a problem as AVM should use .fritzbox.local because they initially didn’t own the fritz.box toplevel domain, and now that they own it still have not fixed it to point to your local Fritz!Box, see the links further below)

    The odd thing is that 3. is not available (meaning there seems to be no way to retrieve the name ending in .local); neither is 5.: scutil --get LocalHostName returns HostName: not set.

  • Likely at least generated in part from [WaybackSave/Archive] scutil.8 is [WaybackSave/Archive] scutil Man Page – macOS – SS64.com:

    scutil

    Manage system configuration parameters.
    Syntax
       Interface to the [raw] stored preference data:

       Report and update a select group of persistent system preferences, e.g. Hostname:
          scutil --get pref
          scutil --set pref [newval]
    
       Report the current DNS configuration:
          scutil --dns
    
       Report the current system proxy configuration:
          scutil --proxy

       --get pref
          Retrieves the specified preference.  The current value will be
          reported on standard output.
    
          Supported preferences include:
    
                ComputerName   The user-friendly name for the system.
    
                LocalHostName  The local (Bonjour) host name.
    
                HostName       The name associated with hostname(1) and
                               gethostname(3).
    
       --set pref [newval]
          Updates the specified preference with the new value.  If the new
          value is not specified on the command line then it will be read from
          standard input.
    
          Supported preferences include: ComputerName LocalHostName HostName
    
          The --set option requires super-user access.
    
       --dns
          Reports the current DNS configuration.
    
       --proxy
          Reports the current proxy configuration.

    Display the current hostname, localhost name and computername:
    scutil --get HostName
    scutil --get LocalHostName
    scutil --get ComputerName
    Change the primary hostname of the computer to cedric.local (local) or cedric.ss64.com (fully qualified):
    sudo scutil --set HostName cedric.local
    sudo scutil --set HostName cedric.ss64.com
    Change the Bonjour hostname of the computer on the local network, to cedric:
    sudo scutil --set LocalHostName cedric
    Change the computer name to Cedric, this is the computer name you see in Finder:
    sudo scutil --set ComputerName Cedric

    Related macOS commands

    hostname – Set or Print the hostname of the current system.
    dscacheutil -flushcache
  • [Wayback/Archive] hostname Man Page – macOS – SS64.com
    Print or Set (temporarily) the name of current host system.
    Syntax
       hostname [-fs] [name-of-host]
    
    Key
       -f    Include domain information in the printed name.
             This is the default behavior.
    
       -s    Trim off any domain information from the printed name.
    The super-user can set the hostname by supplying a hostname argument.

  • [Wayback/Archive] dscacheutil Man Page – macOS – SS64.com
    Directory Service cache – Gather information, statistics, initiate queries, flush the cache.
    dscacheutil replaces most of the functionality of thelookupd tool provided prior to OS X Leopard.
    Syntax
    
          dscacheutil -q category [-a key value]
    
          dscacheutil -cachedump [-buckets] [-entries [category]]
    
          dscacheutil -configuration
    
          dscacheutil -flushcache
    
          dscacheutil -statistics
    
          dscacheutil -h

AVM and the fritz.box domain

By now at least AVM owns the fritz.box domain.

Initially they didn’t. This is a good start to read about that: [Wayback/Archive] Status of hijacked domain Fritz.box ? : fritzbox

It misses the current state links to these that show the current state (AVM owning the fritz.box domain):

More links in chronological order:

  1. [Wayback/Archive] Introducing .box – The World’s First Blockchain Native, DNS Routable Domain
  2. [Wayback/Archive] Verwirrend: Internet-Domain fritz.box zeigt NFT-Galerie statt Router-Verwaltung | heise online
  3. [Wayback/Archive] Fritz.box: Domain aus dem Verkehr gezogen | heise online
  4. [Wayback/Archive] Schiedsverfahren gewonnen: Domain “fritz.box” gehört nun AVM | heise online

Queries:

--jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.