发布服务的同一 IAM 主账号必须在 Google Search Console 中确认自己拥有该网域的 Owner 权限。如需了解详情,请参阅使用 Private Service Connect 发布服务中的准备工作。
服务使用方的自动 DNS 配置
如果存在以下配置,则系统会为端点自动创建 DNS 条目:
服务提供方已为服务配置域名。
端点配置了 IPv4 地址。
端点已向 Service Directory 命名空间注册。
所有新端点都会自动向 Service Directory 注册,但旧端点可能不会注册。
如果两个配置都存在,则端点创建时,系统会创建名为 NAMESPACE--REGION 的 Service Directory DNS 区域。此专用区域存储位于 REGION 区域的 Service Directory 命名空间 NAMESPACE 中的服务的 DNS 条目。NAMESPACE--REGION 的字符数限制为不超过 63 个字符。
图 1.
使用 Service Directory 的端点的自动 DNS 配置(点击可放大)。
创建端点后,您可以验证 Service Directory DNS 区域是否已创建。如果 Service Directory DNS 区域未创建,您可以手动创建类似的配置。如需了解详情,请参阅查看 Service Directory DNS 区域。
如果您不希望创建这些 DNS 条目,请执行以下操作之一:
如果您没有将 Cloud DNS 用于其他目的,请停用 Cloud DNS API 或移除 Cloud DNS 所需的权限。
[[["易于理解","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-09-05。"],[],[],null,["# DNS configuration for published services\n========================================\n\nService producers can [publish services by using\nPrivate Service Connect](/vpc/docs/configure-private-service-connect-producer).\nThe service producer can optionally configure a DNS domain name to associate\nwith the service. If a domain name is configured, and a\n[service consumer creates an endpoint that targets that\nservice](/vpc/docs/configure-private-service-connect-services), Private Service Connect\nand Service Directory automatically create DNS entries for the\nservice in a private DNS zone in the service consumer's VPC\nnetwork.\n\nDNS configuration for service producers\n---------------------------------------\n\nWhen you publish a service (create a service attachment), you can optionally\nconfigure a DNS domain name.\n\nIf you configure a domain name for a service, when a Private Service Connect endpoint is created that connects to that\nservice, the following configurations are made in the service consumer's\nVPC network:\n\n- A [Service Directory DNS\n zone](/service-directory/docs/configuring-service-directory-zone) is created for\n the specified domain.\n\n- A DNS entry for each endpoint is\n created in the zone.\n\nThe recommended format for the domain name is\n\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e`.p.`\u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e. Because this domain name is\nused to create DNS entries in the service consumer's VPC network,\nit's important to use a name that doesn't conflict with any existing DNS domain\nnames. Using this format reduces the risk of conflicts.\n\nFor example, if the service is configured with the domain name\n`us-west1.p.example.com`, and the service consumer creates an\nendpoint with the name `analytics`, a DNS\nrecord for `analytics.us-west1.p.example.com` is automatically created.\n\nThe load balancer that is hosting the service must be able to accept requests\ndirected to this domain name. If you are using an internal Application Load Balancer, you\nmight need to update the load balancer configuration to reflect the domain\nnames that you want service consumers to use. For example, update\n[certificates](/load-balancing/docs/ssl-certificates) or\n[URL maps](/load-balancing/docs/url-map-concepts).\n\nThe same IAM principal that [publishes the\nservice](/vpc/docs/configure-private-service-connect-producer) must confirm that\nthey have Owner permissions for the domain in the Google Search\nConsole. For more information, see [Before you\nbegin](/vpc/docs/configure-private-service-connect-producer#before) in\n*Publish services by using Private Service Connect*.\n\nAutomatic DNS configuration for service consumers\n-------------------------------------------------\n\nIf the following configurations are present, DNS entries are automatically\ncreated for endpoints:\n\n- The service producer has configured a domain name for the service.\n\n- The endpoint is configured with an IPv4 address.\n\n- The endpoint is registered with a\n Service Directory namespace.\n\n All new endpoints are automatically registered with\n Service Directory, but older endpoints might not be registered.\n\nIf both configurations are present, when the\nendpoint is created, a [Service Directory DNS\nzone](/service-directory/docs/configuring-service-directory-zone) is created\nwith the name \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e`--`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e.\nThis private zone stores DNS entries for services found in the\nService Directory namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e in\nthe region \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e. The character limit for\n\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e`--`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is 63 characters or fewer.\n[](/static/vpc/images/private-service-connect-services-autodns.svg) **Figure 1.**\nAutomatic DNS configuration for\nendpoints using Service Directory (click to enlarge).\n\nAfter you create the endpoint, you can\nverify if a Service Directory DNS zone is created. If the\nService Directory DNS zone is not created, you can manually\ncreate a similar configuration. For more information, see [View\nService Directory DNS zones](/vpc/docs/configure-private-service-connect-services#view-private-zones).\n\nIf you don't want these DNS entries to be created, do one of the following:\n\n- If you're not using Cloud DNS for another purpose, disable the\n Cloud DNS API, or remove the permissions that are required for\n Cloud DNS.\n\n- Wait for the DNS zone to be created, then [Delete the DNS\n zone](/dns/docs/zones#deleting_a_managed_zone) manually.\n\n If you want to manually configure DNS, see [Configure DNS\n manually](/vpc/docs/configure-private-service-connect-services#configure-dns-manual)."]]