# Hostname changes after reboot for Google Compute Engine Instances

**URL:** <https://community.replicated.com/t/hostname-changes-after-reboot-for-google-compute-engine-instances/1386>\
**Category:** Supporting your customers\
**Tags:** kots, support, airgap, kurl, troubleshoot\
**Created:** [March 11, 2024, 11:34pm UTC](https://community.replicated.com/t/hostname-changes-after-reboot-for-google-compute-engine-instances/1386 "2024-03-11T23:34:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![diamon\_w](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/diamon_w/32/150_2.png) [@diamon\_w](https://community.replicated.com/u/diamon_w)\
**Post date:** [March 11, 2024, 11:34pm UTC](https://community.replicated.com/t/hostname-changes-after-reboot-for-google-compute-engine-instances/1386/1 "2024-03-11T23:34:21Z")

</div>

On GCP, for instances created running Linux distributions which utilize Network Manager, it’s possible after a reboot to observe issues with a running Kubernetes cluster like kURL where pods are unable to start and the node reports as `NotReady`. Upon further investigation you may see the following in the `kubelet` logs:

`kubelet_node_status.go:92] "Unable to register node with API server" err="nodes \"some-node\" is forbidden: node \"some-node.some.domain.internal\" is not allowed to modify node \"some-node\"" node="some-node"`

This happens in certain Linux distributions on GCP where a script at the location of `/etc/dhcp/dhclient.d/google_hostname.sh` is run whenever the DHCP client renews its lease. This script runs the command `nmcli general hostname "${new_host_name%%.*}"` to set the hostname to the short hand name. Before the script is run, the hostname is generally the full fqdn(`some-node.some.domain.internal`), and afterwards the hostname is simply `some-node` causing the node to enter a `NotReady` state.

To workaround this you can either:

1. Remove the script before running the kURL install with `rm -rf /etc/dhcp/dhclient.d/google_hostname.sh`. It’s worth noting that this approach may affect functionality like `gcloud compute instances create vmname --hostname=xxxx`, so you should proceed with caution.

2. Manually force the script to run as part of the DHCP lease renewal process before running the kURL install with `dhclient -r && dhclient`.

3. Set a permenant hostname manually. [Google Compute Engine: how to set hostname permanently? - Stack Overflow](https://stackoverflow.com/a/25552840)

Relevant Links:

> <https://stackoverflow.com/questions/41309488/hostname-and-etc-hosts-keep-changing-to-instance-project-name-after-network-res>

[https://groups.google.com/g/gce-discussion/c/fi2j7oP8bGM](https://groups.google.com/g/gce-discussion/c/fi2j7oP8bGM)

> **[Hostname resets on restart on Google Cloud Platform](https://support.cpanel.net/hc/en-us/articles/360051577933-Hostname-resets-on-restart-on-Google-Cloud-Platform)**
>
> Symptoms
> On Google Cloud Platform, the system hostname is changed either on boot or after some time. This can cause license errors.
>  
> Description 
> The dhclient script may not preserve the locally c...

---

<div class="post-metadata">

**Author:** ![diamon\_w](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/diamon_w/32/150_2.png) [@diamon\_w](https://community.replicated.com/u/diamon_w)\
**Post date:** [March 19, 2024, 12:57pm UTC](https://community.replicated.com/t/hostname-changes-after-reboot-for-google-compute-engine-instances/1386/2 "2024-03-19T12:57:59Z")

</div>

A bug has been opened for this upstream with the GCP team [bug: `google_set_hostname` changes hostname after reboot · Issue #69 · GoogleCloudPlatform/guest-configs · GitHub](https://github.com/GoogleCloudPlatform/guest-configs/issues/69)
