Terminal showing 192 instead of computername [duplicate]

For three days straight, I have connected to the public WiFi network at my local library. Each day, I have seen a different prompt in Terminal. Here are some of the prompts I've seen:

zp-pc:~ russell$
mary-pc:~ russell$
normob05:~ russell$

I have check under System Preferences -> Sharing, and my computer name is "Russell's Mac". Also, I set the DHCP Client ID to "RUSSMAC" under System Preferences -> Network -> Advanced -> TCP/IP, but I still see the random host names at the Terminal prompt.

Why is my computer name changing every day?


Solution 1:

Type in Terminal:

scutil --get HostName

If there's no HostName available, what you see is probably coming from the DNS or DHCP server.

Set your HostName with:

sudo scutil --set HostName 'yourHostName'

That should do it.

Solution 2:

Found the answer here, though there is some discussion about the details.

In short, the Mac will pick up a host name from the DHCP server. This does not affect your computer's name as you have assigned it. This will only affect what you see at the command prompt.

Solution 3:

Very simple easy solution ...

  1. sudo hostname [name-of-host]

  2. Enter hostname and see your new hostname set

e.g.

doolally:~ sjohnson$ sudo hostname AllTheRage
doolally:~ sjohnson$ hostname
AllTheRage

Login back in or restart terminal to refresh ...

Also, check usage of hostname in man hostname.