本页面上的部分或全部信息可能不适用于 Trusted Cloud by S3NS。
创建使用跨项目绑定的区域
本页面介绍了如何创建启用了跨项目绑定的可用区。如需了解详细的背景信息,请参阅跨项目绑定。
执行此任务所需的权限
如需执行此任务,您必须已获得以下权限或 IAM 角色。
权限
- 对拥有 VPC 网络的项目的
dns.networks.bindPrivateDNSZone
权限
- 对拥有 DNS 区域的项目的
dns.managedZones.create
权限
角色
限制
- 您的项目必须位于同一组织中。
- 您不能将 DNS 区域与组织外部的项目中的 VPC 网络相关联。
设置跨项目绑定
您可以创建可绑定到同一组织中的另一个项目拥有的网络的代管式专用 DNS 区域。不是在同一项目中指定网络,而是在同一组织下的另一个项目中指定网络的网址。
示例:假设您有两个项目(项目 A 和项目 B)。VPC 网络位于项目 A 中。为确保该 VPC 网络中的所有虚拟机都能够解析项目 B 中的 DNS 区域,请按照以下步骤操作。
要获取网址,请在项目 A 中使用 gcloud compute networks
describe
命令:
gcloud compute networks describe NETWORK_NAME
将 NETWORK_NAME
替换为项目 A 中的 VPC 网络的名称。
输出将网址列为 SelfLink
,即您需要的网址。输出类似于以下内容:
autoCreateSubnetworks: true
creationTimestamp: '2021-08-11T14:07:16.454-07:00'
description: Default network for the project
id: '2485375699124847339'
kind: compute#network
name: default
routingConfig:
routingMode: REGIONAL
selfLink: https://www.googleapis.com/compute/v1/projects/project-a/global/networks/default
subnetworks:
通过在项目 B(您希望在其中创建或管理 DNS 区域)中运行 dns managed-zones create
命令来创建专用 DNS 区域:
gcloud dns managed-zones create NAME \
--dns-name=DNS_SUFFIX \
--description="Cross Project Binding" \
--visibility=private \
--networks=VPC_NETWORK
替换以下内容:
NAME
:您的可用区的名称
DNS_SUFFIX
:您的可用区的 DNS 后缀,例如 example.private
VPC_NETWORK
:有权从项目 A 查询 DNS 区域的共享 VPC 网址,例如 https://www.googleapis.com/compute/v1/projects/project-a/global/networks/default。
这将在项目 B(您希望在其中创建和管理 DNS 区域)中创建一个专用 DNS 区域。您的输出类似于以下内容:
Created
[https://dns.googleapis.com/dns/v1/projects/project-b/managedZones/my-zone].
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-11。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-11。"],[[["This guide outlines the process of creating a managed private zone with cross-project binding enabled, allowing it to be associated with a network in a different project within the same organization."],["To perform this task, users need `dns.networks.bindPrivateDNSZone` permission on the VPC network's project and `dns.managedZones.create` permission on the DNS zone's project, or the `roles/dns.admin` role."],["The projects involved must be within the same organization, and zones cannot be linked to VPC networks outside this organizational boundary."],["The process involves obtaining the VPC network's URL from the first project using the `gcloud compute networks describe` command and then using that URL when creating the private zone in the second project with the `gcloud dns managed-zones create` command."],["The VPC Network will be associated with a DNS zone in a different project within the organization so that all the VMs in that VPC network can resolve the DNS zones."]]],[]]