3

My mac's default hostname is Scott-Johnson.local. In the sharing system preferences, I set the hostname to felucia.local, which takes as expected. However, at some point in the future (usually due to either a restart or waking up from sleep), it resets to Scott-Johnson.local. I have also tried the following in the terminal:

sudo scutil –-set HostName felucia

sudo scutil –-set LocalHostName felucia

sudo scutil –-set ComputerName felucia

Again, it will take for a while, but then reset.

My suspicion is that this is a router problem (i.e. I can assign my computer a static IP instead of DHCP when on my local network). Unfortunately, though, this is a laptop, and I will often use it on other networks where I don't have this ability. How can I verify that this will work outside of the network within my control?

7
  • 1
    What do you mean "it's default hostname"? Mac (computers in general) don't come with a pre-set hostname; it's something that has to be set. Also, prior to setting it, what do you get with the command scutil --get LocalHostName?
    – Allan
    Oct 19, 2018 at 22:35
  • It's a former work computer that I purchased from my old company. The original hostname that it came with was Scott-Johnson.local, so that's what I meant by "default hostname". It keeps getting set back to this, and I'm not sure why. Prior to manually changing the hostname, scutil --get LocalHostName returns Scott-Johnson.
    – jwir3
    Oct 19, 2018 at 22:44
  • It's most likely a DHCP/DNS issue then. In your network (home/work) you're setting the host name. When you go to other networks, it won't try to assign this host name (provided you set it manually as you describe) because those networks won't "know" your MAC address/IP/host name. That said, since you "inherited" this MacBook, you should do a clean install and set up everything per your preferences.
    – Allan
    Oct 19, 2018 at 22:49
  • See this answer: apple.stackexchange.com/questions/211793/…
    – Allan
    Oct 19, 2018 at 22:50
  • @jwir3 Perhaps it's something in a plist file that is overriding what you are trying to set manually via terminal. I'm assuming since you purchased this from your work that they were using some sort of management software to control macOS. I'd highly recommend wiping that machine and installing a fresh copy of macOS. But, if you don't want to go that route then check the files under /Library/Preferences Find out what software is used to manage Mac's and let us know. This would help identify the problem.
    – BsdHelper
    Oct 20, 2018 at 21:16

2 Answers 2

1

Try these two steps:

1) First edit the file /etc/sysctl.conf:

sudo pico -w /etc/sysctl.conf

and add the line:

kern.hostname=felucia

2) Then do this:

sudo sysctl -w kern.hostname=felucia

The first command sets the hostname that should be saved after reboot.

The second command sets the hostname immediately.

I'm not positive this will help, but it's worth trying.

2
  • Hm, no joy here. It still got set back to Scott.Johnson. :(
    – jwir3
    Oct 22, 2018 at 23:02
  • Rats! I was really hopeful that would fix it, although I have to admit I was not overly optimistic it would. Sort of a Hail-Mary attempt. I'm not sure this is solvable any way other than writing a launchd script that will check it periodically and reset it when it goes wrong, which is far from ideal. Sorry I couldn't be more help.
    – TJ Luoma
    Oct 23, 2018 at 4:42
-1

Try scutil --set LocalHostName

should prompt you for sudo perms

scutil --get LocalHostName still was the incorrect setting after I just ran hostname

1
  • The OP hgas already used sudo to run the command
    – mmmmmm
    Nov 19, 2021 at 21:14

You must log in to answer this question.

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