When you create new instance like “my-instance-1”, this mean your instance Host name will be also “my-instance-1” !.
The problem is when you change the host name for example to “myhostname.mydomain.net”, every time you use the Google SSH browser tool, or upgrade the instance, the host name will be automatically changed to “my-instance-1” !.
Why Google SSH browser tool change instance hostname ?
In my CentOS VMs I found that the script
/etc/dhcp/dhclient.d/google_hostname.sh, installed by the
google-compute-engine RPM, actually changed the hostname. This happens when the instance gets its IP address during boot.
While it’s not the long-term solution I really want, for now I simply deleted this script. The hostname I set with
hostnamectl now persists after a reboot.
The script is likely to be exactly the same place in Debian/Ubuntu VMs, but of course I don’t run any of those.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.