本頁面中的部分或全部資訊可能不適用於 Trusted Cloud by S3NS。
建立跨專案繫結可用區
本頁面提供如何建立可啟用跨專案繫結的可用區的操作說明。如需詳細背景資訊,請參閱「跨專案繫結」。
這項工作需要的權限
如要執行這項工作,您必須具備以下權限或以下 IAM 角色。
權限
dns.networks.bindPrivateDNSZone
在擁有虛擬私有雲網路的專案上
dns.managedZones.create
在擁有 DNS 區域的專案上
角色
限制
- 您的專案必須屬於同一個機構。
- 您無法將區域與機構外專案中的 VPC 網路建立關聯。
設定跨專案繫結
您可以建立代管私人可用區,並繫結至同機構中其他專案擁有的網路。請勿在同一個專案中指定網路,而是在同一個機構下的其他專案中指定網路的網址。
範例:假設您有兩個專案:專案 A 和 專案 B。虛擬私有雲網路位於專案 A 中。如要確保該虛擬私有雲網路中的所有 VM 都能解析 專案 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:
在您要建立或管理 DNS 區域的 專案 B 中,執行 dns managed-zones create
指令,即可建立私人區域:
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
:獲授權從 project A 查詢區域的共用 VPC 網址,例如 https://www.googleapis.com/compute/v1/projects/project-a/global/networks/default。
這會在您要建立及管理 DNS 可用區的 專案 B 中建立不公開區域。輸出內容會與下列內容相似:
Created
[https://dns.googleapis.com/dns/v1/projects/project-b/managedZones/my-zone].
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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"]],["上次更新時間: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."]]],[]]