使用 Azure PowerShell 委托 Azure DNS 子域Delegate an Azure DNS subdomain using Azure PowerShell

可以使用 Azure PowerShell 委托 DNS 子域。You can use Azure PowerShell to delegate a DNS subdomain. 例如,如果拥有 contoso.com 域,可将名为 engineering 的子域委托给另一个可以独立于 contoso.com 区域进行管理的单独区域。For example, if you own the contoso.com domain, you can delegate a subdomain called engineering to another, separate zone that you can administer separately from the contoso.com zone.

如果需要,可以使用 Azure 门户来委托子域。If you prefer, you can delegate a subdomain using the Azure Portal.

Note

本文通篇都使用 contoso.com 作为示例。Contoso.com is used as an example throughout this article. 请将 contoso.com 替换为你自己的域名。Substitute your own domain name for contoso.com.

如果没有 Azure 订阅,可在开始前创建一个 1 元人民币试用帐户If you don’t have an Azure subscription, create a 1rmb trial account before you begin.

必备条件Prerequisites

若要委托 Azure DNS 子域,必须先将公共域委托给 Azure DNS。To delegate an Azure DNS subdomain, you must first delegate your public domain to Azure DNS. 有关如何为委托配置名称服务器的说明,请参阅将域委托给 Azure DNSSee Delegate a domain to Azure DNS for instructions on how to configure your name servers for delegation. 将域委托给 Azure DNS 区域后,可以委托子域。Once your domain is delegated to your Azure DNS zone, you can delegate your subdomain.

为子域创建区域Create a zone for your subdomain

首先,为 engineering 域创建区域。First, create the zone for the engineering subdomain.

New-AzDnsZone -ResourceGroupName <resource group name> -Name engineering.contoso.com

记下名称服务器Note the name servers

接下来,记下 engineering 子域的四个名称服务器。Next, note the four name servers for the engineering subdomain.

Get-AzDnsRecordSet -ZoneName engineering.contoso.com -ResourceGroupName <resource group name> -RecordType NS

创建一条测试记录Create a test record

在 engineering 区域中创建一条 A 记录以用于测试。Create an A record in the engineering zone to use for testing.

New-AzDnsRecordSet -ZoneName engineering.contoso.com -ResourceGroupName <resource group name> -Name www -RecordType A -ttl 3600 -DnsRecords (New-AzDnsRecordConfig -IPv4Address 10.10.10.10) 列中的一个值匹配。New-AzDnsRecordSet -ZoneName engineering.contoso.com -ResourceGroupName <resource group name> -Name www -RecordType A -ttl 3600 -DnsRecords (New-AzDnsRecordConfig -IPv4Address 10.10.10.10).

创建 NS 记录Create an NS record

接下来,为 contoso.com 区域中的 engineering 区域创建一条名称服务器 (NS) 记录。Next, create a name server (NS) record for the engineering zone in the contoso.com zone.

$Records = @()
$Records += New-AzDnsRecordConfig -Nsdname <name server 1 noted previously>
$Records += New-AzDnsRecordConfig -Nsdname <name server 2 noted previously>
$Records += New-AzDnsRecordConfig -Nsdname <name server 3 noted previously>
$Records += New-AzDnsRecordConfig -Nsdname <name server 4 noted previously>
$RecordSet = New-AzDnsRecordSet -Name engineering -RecordType NS -ResourceGroupName <resource group name> -TTL 3600 -ZoneName contoso.com -DnsRecords $Records

测试委托Test the delegation

使用 nslookup 测试委托。Use nslookup to test the delegation.

  1. 打开 PowerShell 窗口。Open a PowerShell window.
  2. 在命令提示符下,键入 nslookup www.engineering.contoso.com.At command prompt, type nslookup www.engineering.contoso.com.
  3. 应会收到一条非权威回复,其中显示了地址 10.10.10.10You should receive a non-authoritative answer showing the address 10.10.10.10.

后续步骤Next steps

了解如何为 Azure 中托管的服务配置反向 DNSLearn how to configure reverse DNS for services hosted in Azure.