0% found this document useful (0 votes)
28 views

Create A VM Instance With A Custom Hostname

When creating a virtual machine (VM) instance on Google Cloud, a default internal DNS name is automatically generated from the VM name. You can specify a custom hostname to use a fully qualified domain name instead. While the custom hostname is used for the VM, the internal DNS name is still created and used to connect to the VM internally. You must configure an external DNS record, such as in Cloud DNS, to resolve the custom hostname externally.

Uploaded by

Devesh Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Create A VM Instance With A Custom Hostname

When creating a virtual machine (VM) instance on Google Cloud, a default internal DNS name is automatically generated from the VM name. You can specify a custom hostname to use a fully qualified domain name instead. While the custom hostname is used for the VM, the internal DNS name is still created and used to connect to the VM internally. You must configure an external DNS record, such as in Cloud DNS, to resolve the custom hostname externally.

Uploaded by

Devesh Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Create a VM instance with a custom

hostname
bookmark_border
LINUX WINDOWS

When you create a virtual machine (VM) instance, Google Cloud creates an internal DNS
name from the VM name. Unless you specify a custom hostname, Google Cloud uses the
automatically created internal DNS name as the hostname it provides to the VM.

You can create a VM with a custom hostname by specifying any fully qualified DNS name.
Custom hostnames are useful to maintain conventions or to support requirements for
applications that expect a particular hostname.

Even when you specify a custom hostname, Google Cloud creates the Compute Engine
internal DNS name. You can connect to your VM by using this automatically created internal
DNS record. The internal DNS record resolves to the internal DNS name and not the custom
hostname. With custom hostnames, you still need to create a corresponding DNS record in
the appropriate zone, for example, by using Cloud DNS.

Before you begin


 If you want to use the command-line examples in this guide, do the following:
1. Install or update to the latest version of the Google Cloud CLI.
2. Set a default region and zone.
 If you want to use the API examples in this guide, set up API access.

Limitations
 You must manually configure the DNS record for your custom hostname. Custom
hostnames are not resolved by the automatically created records provided by Compute
Engine internal DNS. You can use any of the following to host the DNS record for the
custom hostname:
 a Cloud DNS public or private zone
 any other public DNS name server
 You cannot change a custom hostname after you have created the VM.

Naming convention
Custom hostnames must conform to RFC 1035 requirements for valid hostnames. To meet
these requirements, custom hostnames must meet the following format specifications:
 The hostname contains at least two labels described as follows:
 Each label contains regular expressions that includes only these characters: [a-
z]([-a-z0-9]*[a-z0-9])?.

 Labels are concatenated with a dot.


 Each label is 1-63 characters long.
 The hostname does not exceed 253 characters.

Not valid: contains a single label

my-host1234

Valid: contains three labels concatenated with dots

my-host1234.example.com

Permissions required for this task

Create a VM with a custom hostname


ConsolegcloudTerraformAPIGoJavaNode.jsPython

Follow the API instructions to create an instance from an image or a snapshot, and specify
the hostname field in the request body.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

{
"name": "VM_NAME",
"hostname": "HOST_NAME",
...
}

Replace the following:

 PROJECT_ID: your project ID

 ZONE: the zone where you want to create the VM

 VM_NAME: the name of the VM

 HOST_NAME: the fully qualified domain hostname that you want to assign

Verify the custom hostname


For Linux VMs, you can verify the hostname by running the hostname -f command on the
VM.
You can also verify the custom hostname by using the Google Cloud console or the Google
Cloud CLI.

Consolegcloud
1. To view the custom hostname for your VM, go to the VM instances page.
Go to VM instances
2. Click the instance name to open the VM instance details page.
3. Review the Hostname section. The Hostname field is visible only if a custom
hostname is set.
What's next
 Connect to Linux VMs.
 Connect to Windows VMs.

You might also like