Stay organized with collections Save and categorize content based on your preferences.
Linux Windows
VMs in the same Virtual Private Cloud network can access each other by using internal DNS names instead of IP addresses.
Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
Use the following procedure to read the internal DNS name assigned to a VM instance. You can get the internal DNS name by querying the hostname
metadata entry.
Query the hostname
metadata:
curl "http://metadata.google.internal/computeMetadata/v1/instance/hostname" \ -H "Metadata-Flavor: Google"Windows VMs
Invoke-RestMethod ` -Headers @{"Metadata-Flavor" = "Google"} ` -Uri "http://metadata.google.internal/computeMetadata/v1/instance/hostname"
The metadata server returns the VM's hostname in one of the following formats, which shows the type of internal DNS name that the VM uses:
VM_NAME
.ZONE
.c
.PROJECT_ID
.internal
VM_NAME
.c
.PROJECT_ID
.internal
In the output:
VM_NAME
: the name of the VMZONE
: the zone where the VM is locatedPROJECT_ID
: the project to which the VM belongsTo access the VM, use the internal DNS name in place of the IP address.
The following example uses ping
to contact a VM that uses zonal DNS. This method works, provided that you have created a firewall rule that allows incoming ICMP traffic to the instance.
$ ping VM_NAME.ZONE.c.PROJECT_ID.internal -c 1 PING VM_NAME.ZONE.c.PROJECT_ID.internal (10.240.0.17) 56(84) bytes of data. 64 bytes from VM_NAME.ZONE.c.PROJECT_ID.internal (10.240.0.17): icmp_seq=1 ttl=64 time=0.136 ms
Replace the following:
VM_NAME
: the name of the VMZONE
: the zone where the VM is locatedPROJECT_ID
: the project to which the VM belongsExcept 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."],[[["VMs within the same Virtual Private Cloud network can communicate using internal DNS names instead of IP addresses."],["To authenticate for Google Cloud services and APIs, you can use the Google Cloud console, gcloud CLI (requiring installation and initialization), or REST API (also using gcloud CLI credentials)."],["The internal DNS name of a VM can be obtained by querying the `hostname` metadata, available in zonal or global DNS formats."],["Access a VM using its internal DNS name by replacing the IP address, ensuring a firewall rule allows incoming traffic."],["The format of the internal DNS name are, for zonal: VM_NAME.ZONE.c.PROJECT_ID.internal and for global: VM_NAME.c.PROJECT_ID.internal."]]],[]]
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