OSX: Computer Name Keeps Changing

root's picture

For several month I had this problem on one of my osx servers: the computer name was keep changing by adding a number at the end. Today was mmd (1), tomorrow mmd (2) and so on.
I have tried several things but nothing was successful until I finally gave up and looked up over the internet.
The solution was found here (link at the end of this article), among other methods. The one below was the most useful to me.

plex:~ osx$ sudo /usr/libexec/PlistBuddy -c "Add :ProgramArguments: string --no-namechange" /System/Library/LaunchDaemons/com.apple.discoveryd.plist
plex:~ osx$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
plex:~ osx$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
plex:~ osx$ sudo scutil --set ComputerName mmd
plex:~ osx$ sudo scutil --set HostName mmd
plex:~ osx$ sudo scutil --set LocalHostName mmd
plex:~ osx$ hostname -f

Source: http://apple.stackexchange.com/questions/153080/computer-name-keeps-changing-osx-10-10-14a389

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself!
Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.