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.
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
Have you tried hostname(1) ?
Change hostname in Google Compute Engine (Cent OS)
Step 1
Step 2: Create crontab auto set Hostname
Step 3
Step 4: Add below
For those who want to have a permanent hostname (for CentOS 6 & 7):