VM instance - annoying hostname change

63 views
Skip to first unread message

David Adamyan

unread,
Jan 10, 2018, 9:05:20 AM1/10/18
to gce-discussion
I've a VM instance running on GCE with WHM/cPanel.

There is a one BIG problem I can't get rid of it:
THE HOSTNAME

My hostname must be set: host.example.com

At every reboot of the server or any actual change the servers hostname changes to "host"  which is in this case the name of my instance!
Which cause Invalid license error on WHM/cPanel.

How to prevent this?  Thank you for your time.

Karthick (Cloud Platform Support)

unread,
Jan 10, 2018, 5:22:38 PM1/10/18
to gce-discussion
Hello David, 

What type of distribution are you running?  The hostname is set via DHCP exit hook (/etc/dhcp/dhclient-exit-hooks) and will be re-configured to match the instance name anytime the network is brought up. More details can be found here. Host name is based off the client name which comes from the metadata server. 

However, you may try the following in the startup-script from "custom metadata" of your instance :

1. Select the VM instance and then click Edit button
2. In the custom metadata field, enter the following: 
Key: hostname
Value: $HOSTNAME

*change the $HOSTNAME with your preferred hostname (host.example.com)
3. Then click save. 

Please let me know of the result. 








David Adamyan

unread,
Jan 22, 2018, 5:02:23 PM1/22/18
to gce-discussion
Hello Karthick,

Thank you for explanation. 

The problem is already solved.
Indeed the way you mentioned it.

Regards,

David


David Adamyan

unread,
Mar 2, 2018, 4:31:15 AM3/2/18
to gce-discussion
Hello Karthick,

I'm having the same problem again for the last days, the hostname is manually changing.

Everything was working just fine...

I've checked the folder you mentioned:  /etc/dhcp/dhclient-exit-hooks
And there is just one file called "azure-cloud.sh" !

Does this have anything to do with it?
Reply all
Reply to author
Forward
0 new messages