Muhammad Jamshed
Muhammad Jamshed

Reputation: 31

How can I set a static hostname in google cloud VM?

I want to configure a static hostname for my google cloud VM instance as currently its reverted to default hostname once the instance is restarted.

I have followed a few tutorials but none of those worked and thus need a permanent solution.

Regards

Upvotes: 1

Views: 1787

Answers (1)

Tux
Tux

Reputation: 2065

The hostname in Google Cloud Platform is used for internal DNS resolution by the metadata server and is part of the default metadata for your instance. Changing it would break a few things. If you want to check what's your instance's hostname registered on the metadata server you would do this:

curl http://metadata.google.internal/computeMetadata/v1/instance/hostname -H "Metadata-Flavor: Google"

But actually changing that metadata manually is not possible, but there are several workarounds that might work for you. See this other answer

Upvotes: 1

Related Questions