Title says it all really – I want to change the hostname of a Google Compute Engine Cent OS instance.
I have tried the normal method…
- in
/etc/sysconfig/network
setHOSTNAME=my.new.hostname
- in
/etc/hosts
set127.0.1.1 my.new.hostname
- reboot
I have tried setting a hostname
key/value pair in the Custom metadata
of the Compute Engine
VM Instance
admin page.
Nothing sticks. Seems to use the instance name as hostname.
Best Answer
By default there is a start up script which sets the hostname according to the metadata of that instance.
See: https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/google-startup-scripts