在 Azure DNS 中托管反向 DNS 查找区域Host reverse DNS lookup zones in Azure DNS

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

本文介绍如何在 Azure DNS 中托管所分配的 IP 范围的反向 DNS 查找区域。This article explains how to host the reverse DNS lookup zones for your assigned IP ranges in Azure DNS. 必须将反向查找区域表示的 IP 范围分配给组织(通常通过 ISP 执行)。The IP ranges represented by the reverse lookup zones must be assigned to your organization, typically by your ISP.

若要为分配给 Azure 服务的 Azure 拥有的 IP 地址配置反向 DNS,请参阅为 Azure 中托管的服务配置反向 DNSTo configure reverse DNS for an Azure-owned IP address that's assigned to your Azure service, see Configure reverse DNS for services hosted in Azure.

阅读本文之前,应已熟悉此反向 DNS 和 Azure 支持概述Before you read this article, you should be familiar with the overview of reverse DNS and support in Azure.

本文将逐步指导用户使用 Azure 门户、Azure PowerShell、Azure 经典 CLI 或 Azure CLI 创建自己的第一个 DNS 区域和记录。This article walks you through the steps to create your first reverse lookup DNS zone and record by using the Azure portal, Azure PowerShell, Azure classic CLI, or Azure CLI.

创建反向查找 DNS 区域Create a reverse lookup DNS zone

  1. 登录 Azure 门户Sign in to the Azure portal.

  2. 在“中心”菜单上,选择“新建”> 搜索“DNS 区域”,然后选择“DNS 区域”。 On the Hub menu, select New >search DNS zone, and then select DNS zone.

    “DNS 区域”选项

  3. 在“创建 DNS 区域”窗格中,命名 DNS 区域。 In the Create DNS zone pane, name your DNS zone. IPv4 和 IPv6 前缀的区域名称不同。The name of the zone is crafted differently for IPv4 and IPv6 prefixes. 使用有关 IPv4IPv6 的说明为区域命名。Use the instructions for IPv4 or IPv6 to name your zone. 完成后,选择“创建”以创建区域。 When you're finished, select Create to create the zone.

IPv4IPv4

IPv4 反向查找区域的名称基于其所代表的 IP 范围。The name of an IPv4 reverse lookup zone is based on the IP range that it represents. 应采用以下格式:<IPv4 network prefix in reverse order>.in-addr.arpaIt should be in the following format: <IPv4 network prefix in reverse order>.in-addr.arpa. 有关示例,请参阅反向 DNS 和 Azure 支持概述For examples, see Overview of reverse DNS and support in Azure.

备注

在 Azure DNS 中创建无类别反向 DNS 查找区域时,区域名称中必须使用连字符 (-) 而不是正斜杠 (/)。When you're creating classless reverse DNS lookup zones in Azure DNS, you must use a hyphen (-) rather than a forward slash (/) in the zone name.

例如,对于 IP 范围 192.0.2.128/26,区域名称必须为 128-26.2.0.192.in-addr.arpa,而不是 128/26.2.0.192.in-addr.arpaFor example, for the IP range 192.0.2.128/26, you must use 128-26.2.0.192.in-addr.arpa as the zone name instead of 128/26.2.0.192.in-addr.arpa.

虽然 DNS 标准支持这两种形式,但 Azure DNS 中不支持包含正斜杠 (/) 字符的 DNS 区域名称。Although the DNS standards support both methods, Azure DNS doesn't support DNS zone names that contain for forward slash (/) character.

以下示例演示如何通过 Azure 门户在 Azure DNS 中创建名为 2.0.192.in-addr.arpa 的“类 C”的反向 DNS 区域:The following example shows how to create a Class C reverse DNS zone named 2.0.192.in-addr.arpa in Azure DNS via the Azure portal:

“创建 DNS 区域”窗格,已填写其中的输入框

“资源组位置”定义资源组的位置。 Resource group location defines the location for the resource group. 它对 DNS 区域没有影响。It has no impact on the DNS zone. DNS 区域位置始终是“全局”,并且不会显示。The DNS zone location is always "global," and is not shown.

以下示例演示如何通过 Azure PowerShell 和 Azure CLI 完成此任务。The following examples show how to complete this task by using Azure PowerShell and Azure CLI.

PowerShellPowerShell

New-AzDnsZone -Name 2.0.192.in-addr.arpa -ResourceGroupName MyResourceGroup

Azure 经典 CLIAzure classic CLI

azure network dns zone create MyResourceGroup 2.0.192.in-addr.arpa

Azure CLIAzure CLI

az network dns zone create -g MyResourceGroup -n 2.0.192.in-addr.arpa

IPv6IPv6

IPv6 反向查找区域的名称应采用以下格式:<IPv6 network prefix in reverse order>.ip6.arpaThe name of an IPv6 reverse lookup zone should be in the following form: <IPv6 network prefix in reverse order>.ip6.arpa. 有关示例,请参阅反向 DNS 和 Azure 支持概述For examples, see Overview of reverse DNS and support in Azure.

下面的示例演示如何通过 Azure 门户在 Azure DNS 中创建名为 0.0.0.0.d.c.b.a.8.b.d.0.1.0.0.2.ip6.arpa 的 IPv6 反向 DNS 查找区域:The following example shows how to create an IPv6 reverse DNS lookup zone named 0.0.0.0.d.c.b.a.8.b.d.0.1.0.0.2.ip6.arpa in Azure DNS via the Azure portal:

“创建 DNS 区域”窗格,已填写其中的输入框

“资源组位置”定义资源组的位置。 Resource group location defines the location for the resource group. 它对 DNS 区域没有影响。It has no impact on the DNS zone. DNS 区域位置始终是“全局”,并且不会显示。The DNS zone location is always "global," and is not shown.

以下示例演示如何通过 Azure PowerShell 和 Azure CLI 完成此任务。The following examples show how to complete this task by using Azure PowerShell and Azure CLI.

PowerShellPowerShell

New-AzDnsZone -Name 0.0.0.0.d.c.b.a.8.b.d.0.1.0.0.2.ip6.arpa -ResourceGroupName MyResourceGroup

Azure 经典 CLIAzure classic CLI

azure network dns zone create MyResourceGroup 0.0.0.0.d.c.b.a.8.b.d.0.1.0.0.2.ip6.arpa

Azure CLIAzure CLI

az network dns zone create -g MyResourceGroup -n 0.0.0.0.d.c.b.a.8.b.d.0.1.0.0.2.ip6.arpa

委托反向 DNS 查找区域Delegate a reverse DNS lookup zone

创建反向 DNS 查找区域后,必须确保从父区域委托该区域。Now that you've created your reverse DNS lookup zone, you must ensure that the zone is delegated from the parent zone. DNS 委托使 DNS 名称解析过程能够找到托管反向 DNS 查找区域的名称服务器。DNS delegation enables the DNS name resolution process to find the name servers that host your reverse DNS lookup zone. 如此,这些名称服务器便可响应针对地址范围内 IP 地址的 DNS 反向查询。Those name servers can then answer DNS reverse queries for the IP addresses in your address range.

对于前向查找区域,将域委托给 Azure DNS 中介绍了相关 DNS 区域委托过程。For forward lookup zones, the process of delegating a DNS zone is described in Delegate your domain to Azure DNS. 反向查找区域的委托方式与之相同。Delegation for reverse lookup zones works the same way. 唯一的区别是,需使用提供 IP 范围的 ISP(而不是域名注册机构)配置名称服务器。The only difference is that you need to configure the name servers with the ISP that provided your IP range, rather than your domain name registrar.

创建 DNS PTR 记录Create a DNS PTR record

IPv4IPv4

以下示例指导用户在 Azure DNS 的反向 DNS 区域中创建 PTR 记录。The following example walks you through the process of creating a PTR record in a reverse DNS zone in Azure DNS. 若要了解其他记录类型并修改现有记录,请参阅使用 Azure 门户管理 DNS 记录和记录集For other record types and to modify existing records, see Manage DNS records and record sets by using the Azure portal.

  1. 在“DNS 区域” 窗格顶部,选择“+ 记录集” 打开“添加记录集” 窗格。At the top of the DNS zone pane, select + Record set to open the Add record set pane.

    用于创建记录集的按钮

  2. PTR 记录的记录集名称需为以倒序排序的 IPv4 地址的其余部分。The name of the record set for a PTR record needs to be the rest of the IPv4 address in reverse order.

    在此示例中,已填充前三个八进制数,作为区域名称 (.2.0.192) 的一部分。In this example, the first three octets are already populated as part of the zone name (.2.0.192). 因此,“名称”框中提供仅最后一个八进制数。 Therefore, only the last octet is supplied in the Name box. 例如,对于 IP 地址为 192.0.2.15 的资源,可将记录集命名为 15For example, you might name your record set 15 for a resource whose IP address is 192.0.2.15.

  3. 对于“类型”,请选择“PTR”。 For Type, select PTR.

  4. 在“域名”字段中,输入使用该 IP 的资源的完全限定域名 (FQDN) 。For DOMAIN NAME, enter the fully qualified domain name (FQDN) of the resource that uses the IP.

  5. 单击窗格底部的“确定”创建 DNS 记录。 Select OK at the bottom of the pane to create the DNS record.

    “添加记录集”窗格,已填写其中的输入框

以下示例演示如何使用 PowerShell 或 Azure CLI 完成此任务。The following examples show how to complete this task by using PowerShell or Azure CLI.

PowerShellPowerShell

New-AzDnsRecordSet -Name 15 -RecordType PTR -ZoneName 2.0.192.in-addr.arpa -ResourceGroupName MyResourceGroup -Ttl 3600 -DnsRecords (New-AzDnsRecordConfig -Ptrdname "dc1.contoso.com")

Azure 经典 CLIAzure classic CLI

azure network dns record-set add-record MyResourceGroup 2.0.192.in-addr.arpa 15 PTR --ptrdname dc1.contoso.com  

Azure CLIAzure CLI

az network dns record-set ptr add-record -g MyResourceGroup -z 2.0.192.in-addr.arpa -n 15 --ptrdname dc1.contoso.com

IPv6IPv6

以下示例将指导用户创建新的 PTR 记录。The following example walks you through the process of creating new PTR record. 若要了解其他记录类型并修改现有记录,请参阅使用 Azure 门户管理 DNS 记录和记录集For other record types and to modify existing records, see Manage DNS records and record sets by using the Azure portal.

  1. 在“DNS 区域” 窗格顶部,选择“+ 记录集” 打开“添加记录集” 窗格。At the top of the DNS zone pane, select + Record set to open the Add record set pane.

    用于创建记录集的按钮

  2. PTR 记录的记录集名称需为以倒序排序的 IPv6 地址的其余部分。The name of the record set for a PTR record needs to be the rest of the IPv6 address in reverse order. 不能包含任何零压缩。It must not include any zero compression.

    在此示例中,已填充 IPv6 的前 64 位,作为区域名称的一部分 (0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa)。In this example, the first 64 bits of the IPv6 are already populated as part of the zone name (0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa). 因此,“名称”框中仅提供了最后 64 位。 Therefore, only the last 64 bits are supplied in the Name box. 以倒序顺序输入 IP 地址的后 64 位,使用句点作为十六进制数之间的分隔符。The last 64 bits of the IP address are entered in reverse order, with a period as the delimiter between each hexadecimal number. 例如,对于 IP 地址为 2001:0db8:abdc:0000:f524:10bc:1af9:405e 的资源,可将记录集命名为 e.5.0.4.9.f.a.1.c.b.0.1.4.2.5.fFor example, you might name your record set e.5.0.4.9.f.a.1.c.b.0.1.4.2.5.f for a resource whose IP address is 2001:0db8:abdc:0000:f524:10bc:1af9:405e.

  3. 对于“类型”,请选择“PTR”。 For Type, select PTR.

  4. 在“域名”字段中,输入使用该 IP 的资源的 FQDN 。For DOMAIN NAME, enter the FQDN of the resource that uses the IP.

  5. 单击窗格底部的“确定”创建 DNS 记录。 Select OK at the bottom of the pane to create the DNS record.

“添加记录集”窗格,已填写其中的输入框

以下示例演示如何使用 PowerShell 或 Azure CLI 完成此任务。The following examples show how to complete this task by using PowerShell or Azure CLI.

PowerShellPowerShell

New-AzDnsRecordSet -Name "e.5.0.4.9.f.a.1.c.b.0.1.4.2.5.f" -RecordType PTR -ZoneName 0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa -ResourceGroupName MyResourceGroup -Ttl 3600 -DnsRecords (New-AzDnsRecordConfig -Ptrdname "dc2.contoso.com")

Azure 经典 CLIAzure classic CLI

azure network dns record-set add-record MyResourceGroup 0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa e.5.0.4.9.f.a.1.c.b.0.1.4.2.5.f PTR --ptrdname dc2.contoso.com 

Azure CLIAzure CLI

az network dns record-set ptr add-record -g MyResourceGroup -z 0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa -n e.5.0.4.9.f.a.1.c.b.0.1.4.2.5.f --ptrdname dc2.contoso.com

查看记录View records

若要查看创建的记录,请在 Azure 门户中浏览到 DNS 区域。To view the records that you created, browse to your DNS zone in the Azure portal. 在“DNS 区域”窗格的下半部分,可以看到 DNS 区域的记录。 In the lower part of the DNS zone pane, you can see the records for the DNS zone. 应会看到默认的 NS 和 SOA 记录以及创建的新记录。You should see the default NS and SOA records, plus any new records that you've created. NS 和 SOA 记录已在每个区域中创建。The NS and SOA records are created in every zone.

IPv4IPv4

“DNS 区域”窗格显示 IPv4 PTR 记录: The DNS zone pane shows the IPv4 PTR records:

“DNS 区域”窗格,其中包含 IPv4 记录

以下示例演示如何使用 PowerShell 或 Azure CLI 查看 PTR 记录。The following examples show how to view the PTR records by using PowerShell or Azure CLI.

PowerShellPowerShell

Get-AzDnsRecordSet -ZoneName 2.0.192.in-addr.arpa -ResourceGroupName MyResourceGroup

Azure 经典 CLIAzure classic CLI

azure network dns record-set list MyResourceGroup 2.0.192.in-addr.arpa

Azure CLIAzure CLI

az network dns record-set list -g MyResourceGroup -z 2.0.192.in-addr.arpa

IPv6IPv6

“DNS 区域”窗格显示 IPv6 PTR 记录: The DNS zone pane shows the IPv6 PTR records:

“DNS 区域”窗格,其中包含 IPv6 记录

以下示例演示如何使用 PowerShell 或 Azure CLI 查看记录。The following examples show how to view the records by using PowerShell or Azure CLI.

PowerShellPowerShell

Get-AzDnsRecordSet -ZoneName 0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa -ResourceGroupName MyResourceGroup

Azure 经典 CLIAzure classic CLI

azure network dns record-set list MyResourceGroup 0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa

Azure CLIAzure CLI

az network dns record-set list -g MyResourceGroup -z 0.0.0.0.c.d.b.a.8.b.d.0.1.0.0.2.ip6.arpa

常见问题解答FAQ

是否可以在 Azure DNS 上托管 ISP 分配的 IP 块的反向 DNS 查找区域?Can I host reverse DNS lookup zones for my ISP-assigned IP blocks on Azure DNS?

是的。Yes. 完全支持在 Azure DNS 托管自己的 IP 范围的反向查找 (ARPA) 区域。Hosting the reverse lookup (ARPA) zones for your own IP ranges in Azure DNS is fully supported.

按照本文所述步骤在 Azure DNS 中创建反向查找区域,然后使用 ISP 委托区域Create the reverse lookup zone in Azure DNS as explained in this article, and then work with your ISP to delegate the zone. 然后,便可以像处理其他记录类型一样,管理每个反向查找的 PTR 记录。You can then manage the PTR records for each reverse lookup in the same way as other record types.

托管反向 DNS 查找区域的成本是多少?How much does hosting my reverse DNS lookup zone cost?

在 Azure DNS 中托管 ISP 分配的 IP 块的反向 DNS 查找区域根据标准 Azure DNS 费率收费。Hosting the reverse DNS lookup zone for your ISP-assigned IP block in Azure DNS is charged at standard Azure DNS rates.

是否可以在 Azure DNS 中托管 IPv4 和 IPv6 地址的反向 DNS 查找区域?Can I host reverse DNS lookup zones for both IPv4 and IPv6 addresses in Azure DNS?

是的。Yes. 本文介绍如何在 Azure DNS 中创建 IPv4 和 IPv6 的反向 DNS 查找区域。This article explains how to create both IPv4 and IPv6 reverse DNS lookup zones in Azure DNS.

是否可以导入现有的反向 DNS 查找区域?Can I import an existing reverse DNS lookup zone?

是的。Yes. 可以使用 Azure CLI 将现有的 DNS 区域导入 Azure DNS。You can use Azure CLI to import existing DNS zones into Azure DNS. 此方法适用于正向查找区域和反向查找区域。This method works for both forward lookup zones and reverse lookup zones.

有关详细信息,请参阅使用 Azure CLI 导入和导出 DNS 区域文件For more information, see Import and export a DNS zone file using Azure CLI.

后续步骤Next steps

有关反向 DNS 的详细信息,请参阅反向 DNS 查找For more information on reverse DNS, see reverse DNS lookup on Wikipedia.
了解如何管理 Azure 服务的反向 DNS 记录Learn how to manage reverse DNS records for your Azure services.