52

I have a local network at home. This network contains 5 laptops. One of the laptops is a Mac with macOS 10.8 on it. The other has a Linux installed, all others run Windows.

When trying to open my router and check "Connected devices", under the IP address of this Mac I see following:

Host Name - some IPV6 address

What I'd rather prefer to see is some meaningful name so that I can use that in the /etc/hosts file in Linux laptop. And also I'd like to check the computer name so that the /etc/hosts line was proper.

93

Setting the Mac hostname or computer name from the terminal

  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>
    
  3. 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>
    
  4. If you also want to change the computer name, type the following command:
    This is the user-friendly computer name you see in Finder, for example myMac.

    sudo scutil --set ComputerName <new name>
    
  5. Flush the DNS cache by typing:

    dscacheutil -flushcache
    
  6. Restart your Mac.

4
  • after doing this I still see the IPv6 address in the router. Any idea? And what would be the line in the /etc/hosts file on Linux if I set the hostnames to MyMac?
    – Igor
    Jun 24 '17 at 16:37
  • 2
    Always attribute quoted content with an appropriate source link and use quote formatting for quoted content. I've added a potential source link but please edit if this is incorrect.
    – grg
    Jun 24 '17 at 22:10
  • 1
    scutil --get HostName shows the current value of HostName. Jan 26 at 21:56
  • Should we done all steps?
    – alper
    Jun 28 at 9:49
13

You can set the computer name in System Preferences → Sharing.

4
  • @ggarside, I still see an IPv6 as a computer name inside the router. It is a Comcast modem/router one. Any idea?
    – Igor
    Jun 25 '17 at 1:25
  • 1
    this doesn't seem to change the hostname returned by the hostname command in terminal
    – Woodstock
    Dec 12 '20 at 13:53
  • 1
    @Woodstock it does seem to be linked somehow, but does not get updated immediately
    – Magnus
    Jan 6 at 1:25
  • @grg Do you know what this difference is between this and the NetBIOS Name in the Network -> Advanced section of Preferences? Jul 9 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .