My mac's hostname keeps getting reset to default

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?


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.