As @John Hanley replied you can configure your own hostname when creating an instance.
For example you create an instance vm1
with custom name mycustomname.xxxx.xxx
. When you will be trying to ping the instance with custom name you stiull have to use vm1
or the IP. This is due to the GCP's Internal DNS behavior:
You can specify a custom hostname for a VM when you create it. Custom
hostnames assigned in this way are not resolved by internal DNS. With
custom hostnames, you still need to create a corresponding DNS record
in the appropriate zone (for example, using Cloud DNS). See creating a
VM instance with a custom hostname for more information.
You can find out even more info about custom hostnames here.
Generally internal DNS will resolve the name of the instances that are visible in the VM's list or running gcloud compute instances list
. Even when you change the hostname at the OS level (sudo hostname my_new_hostname
) it will only be visible to the VM's OS. No other VM will be able to ping this VM using new hostname.