VPN Changes Hostname

When I connect to various VPN servers (Windows PPTP, Cisco IPSEC) the hostname of my laptop gets updated.

Is there a setting somewhere that will stop this from happening?


The VPN's DHCP server probably assigns hostname together with the IP address and the computer uses it instead of what you've set during setup and what appears in System Preferences -> Sharing -> Computer name.

To set a permanent hostname do sudo scutil --set HostName DesiredHostname in Terminal.app (there are also ComputerName and LocalHostName that can be changed there). Restart may be required.


This question is a manifestation of the same situation described in question Why is my host name wrong at the Terminal prompt when connected to a public WiFi network?, and the answer https://apple.stackexchange.com/a/127405/17600 explains the cause and the solution. Copying from that answer:

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.