3

I was not able to refuse changing my hostname by DHCP Server on Mac Book. None of these solutions below worked for me:

After deleting the files as suggested from the Apple engineer it retrieved a new hostname and a new ip. But it wasn't a static hostname. Creating the file /etc/hostconfig doesn't work neither.

I mean come on, that's a well known feature and it should work. Poorly it doesn't for now. I'm sure there must be a solution for this.

As the server we are using a Mac Mini with built-in DNS and DHCP. My Mac Book's system is macOS Sierra 10.12.3

Edit: From the 3rd link, the Apple engineer suggested to delete the following three files in /Libray/Preferences/SystemConfiguration:

com.apple.airport.preferences.plist
NetworkInterfaces.plist
preferences.plist
8

It took a LOT of Googling and digging to get this, but I finally found a solution that works. DHCP overrides the LocalHostName system property, but not the HostName property. By default the HostName is not set in macOS Sierra, so you can set it as well as LocalHostName and ComputerName using scutil:

sudo scutil --set HostName yourcomputername
sudo scutil --set LocalHostName yourcomputername
sudo scutil --set ComputerName "Your Computer name"

The HostName property appears to be permanent. LocalHostName can still be overridden, but it won't override HostName once it's set.

  • Well, I think both solutions would do it. As I prefer the bash, I used your solution. The hostname isnot changed anymore after a few reboots. – alpham8 Mar 6 '17 at 14:58
1

Open /System/Library/LaunchDaemons/com.apple.discoveryd.plist with Xcode and add to the ‘ProgramArguments’ array with the string --no-namechange. Save the file and restart the machine.

  • com.apple.discoveryd.plist as well as /usr/libexec/discoveryd only exist in some Yosemite releases (10.10.0-10.10.3).... – klanomath Mar 2 '17 at 2:37

You must log in to answer this question.

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