A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/compute/docs/instances/custom-hostname-vm below:

Create a VM instance with a custom hostname | Compute Engine Documentation

Skip to main content Create a VM instance with a custom hostname

Stay organized with collections Save and categorize content based on your preferences.

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 Required roles

To get the permissions that you need to create VM with a custom hostname, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to create VM with a custom hostname. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create VM with a custom hostname:

You might also be able to get these permissions with custom roles or other predefined roles.

Limitations Supported operating systems

Custom hostnames are set in the guest environment using hook scripts which integrate with the guest networking software. Linux operating systems that don't have a script to integrate with the guest network software might not have the correct hostname.

For the full list of operating system versions that support custom hostnames, check the guest environment support in Operating system details.

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:

Not valid: contains a single label

my-host1234

Valid: contains three labels concatenated with dots

my-host1234.example.com
Create a VM with a custom hostname Console
  1. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  2. Specify a Name for your VM. For more information, see Resource naming convention.

  3. Expand the Advanced options section, and then do the following:

    1. Expand the Networking section.
    2. In the Hostname field, specify the custom hostname.
  4. Make additional VM customizations, as needed.

  5. To create and start the VM, click Create.

Next step: Configure your DNS records. For more information, see Managing records.

gcloud

Using the Google Cloud CLI, follow the instructions to create an instance from an image or a snapshot, add the --hostname flag, and use the gcloud compute instances create command as follows:

gcloud compute instances create VM_NAME \
    --hostname=HOST_NAME

Replace the following:

For example, to create a VM myinstance with the custom hostname test.example.com, run the following command:

gcloud compute instances create myinstance \
    --hostname=test.example.com

Next step: Configure your DNS records. For more information, see Managing records.

Terraform

You can use a Terraform resource to create an instance with a custom hostname by using the hostname argument.

To generate the Terraform code, you can use the Equivalent code component in the Google Cloud console.
  1. In the Google Cloud console, go to the VM instances page.

    Go to VM Instances

  2. Click Create instance.
  3. Specify the parameters you want.
  4. At the top or bottom of the page, click Equivalent code, and then click the Terraform tab to view the Terraform code.

Next step: Configure your DNS records. For more information, see Managing records.

Go Java Node.js Python REST

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:

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.

Console
  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.

gcloud

To view the custom hostname for your VM using gcloud compute, use the instances describe sub-command with a --format flag to filter the output. Replace VM_NAME with the name of the VM.

gcloud compute instances describe VM_NAME \
    --format='get(hostname)'

For example, to view the custom hostname for a VM named myinstance, run the following command.

gcloud compute instances describe myinstance \
    --format='get(hostname)'

The output might resemble the following:

test.example.com

If a custom hostname is not set, the output for this command is blank.

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Google Cloud automatically generates an internal DNS name for each VM, which is used as the default hostname unless a custom hostname is specified."],["Custom hostnames can be defined for VMs using fully qualified DNS names, but you still need to configure a corresponding DNS record in a zone like Cloud DNS to resolve it."],["Creating a VM with a custom hostname can be done through the Google Cloud Console, gcloud CLI, Terraform, or various programming languages like Go, Java, Node.js, and Python."],["Custom hostnames must adhere to RFC 1035 requirements, including having at least two labels, with each being 1-63 characters long and concatenated with dots."],["Verifying the custom hostname is possible by running the `hostname -f` command on the VM, using the Google Cloud Console, or using the `gcloud compute instances describe` command."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4