[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-29。"],[[["\u003cp\u003eVMs within the same Virtual Private Cloud network can communicate using internal DNS names instead of IP addresses.\u003c/p\u003e\n"],["\u003cp\u003eTo 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).\u003c/p\u003e\n"],["\u003cp\u003eThe internal DNS name of a VM can be obtained by querying the \u003ccode\u003ehostname\u003c/code\u003e metadata, available in zonal or global DNS formats.\u003c/p\u003e\n"],["\u003cp\u003eAccess a VM using its internal DNS name by replacing the IP address, ensuring a firewall rule allows incoming traffic.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"]]],[],null,["Linux Windows\n\n*** ** * ** ***\n\nVMs in the same Virtual Private Cloud network can access each other by using\ninternal DNS names instead of IP addresses.\n\nBefore you begin\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n gcloud\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nDetermine the internal DNS name for a VM\n\nUse the following procedure to read the internal DNS name assigned to a VM\ninstance. You can get the internal DNS name by querying the `hostname` metadata\nentry.\n\n1. [Connect to the VM](/compute/docs/instances/connecting-to-instance).\n2. Query the `hostname` metadata:\n\n Linux VMs \n\n ```\n curl \"http://metadata.google.internal/computeMetadata/v1/instance/hostname\" \\\n -H \"Metadata-Flavor: Google\"\n ```\n\n Windows VMs \n\n ```\n Invoke-RestMethod `\n -Headers @{\"Metadata-Flavor\" = \"Google\"} `\n -Uri \"http://metadata.google.internal/computeMetadata/v1/instance/hostname\"\n ```\n\nThe metadata server returns the VM's hostname in one of the following formats,\nwhich shows the type of internal DNS name that the VM uses:\n\n- **Zonal DNS** : \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e.`c`.\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.`internal`\n- **Global DNS** : \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e.`c`.\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.`internal`\n\nIn the output:\n\n- \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the VM\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone where the VM is located\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project to which the VM belongs\n\nAccess VMs by internal DNS name\n\nTo access the VM, use the internal DNS name in place of the IP address.\n\nThe following example uses `ping` to contact a VM that uses\n[zonal DNS](/compute/docs/networking/zonal-dns). This method works, provided\nthat you have created a [firewall rule](/vpc/docs/firewalls) that allows\nincoming ICMP traffic to the instance. \n\n```\n$ ping VM_NAME.ZONE.c.PROJECT_ID.internal -c 1\n\nPING \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e.c.\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.internal (10.240.0.17) 56(84) bytes of data.\n64 bytes from \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e.c.\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.internal (10.240.0.17): icmp_seq=1 ttl=64 time=0.136 ms\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the VM\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone where the VM is located\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project to which the VM belongs\n\nWhat's next\n\n- Migrate to [zonal DNS](/compute/docs/networking/zonal-dns)\n- Learn more about [internal DNS names for Compute Engine](/compute/docs/internal-dns).\n- [Configure static IP addresses for your VM](/compute/docs/ip-addresses/configure-static-external-ip-address)."]]