您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

快速入门:使用 Azure 门户创建 Azure DNS 区域和记录Quickstart: Create an Azure DNS zone and record using the Azure portal

可以将 Azure DNS 配置为解析公共域中的主机名。You can configure Azure DNS to resolve host names in your public domain. 例如,如果从某个域名注册机构购买了 contoso.xyz 域名,则可配置 Azure DNS 来托管 contoso.xyz 域,并将 www.contoso.xyz 解析为 Web 服务器或 Web 应用的 IP 地址 。For example, if you purchased the contoso.xyz domain name from a domain name registrar, you can configure Azure DNS to host the contoso.xyz domain and resolve www.contoso.xyz to the IP address of your web server or web app.

在本快速入门中,你将创建一个测试域,然后创建一个地址记录来将 www 解析为 IP 地址 10.10.10.10In this quickstart, you will create a test domain, and then create an address record to resolve www to the IP address 10.10.10.10.

重要

本快速入门中的所有名称和 IP 地址都是示例,不代表实际场景。All the names and IP addresses in this quickstart are examples that do not represent real-world scenarios.

如果没有 Azure 订阅,请在开始之前创建一个免费帐户If you don't have an Azure subscription, create a free account before you begin.

对于所有门户步骤,请登录到 Azure 门户For all portal steps, sign in to the Azure portal.

创建 DNS 区域Create a DNS zone

DNS 区域包含域的 DNS 条目。A DNS zone contains the DNS entries for a domain. 若要开始在 Azure DNS 中托管域,请为该域名创建一个 DNS 区域。To start hosting your domain in Azure DNS, you create a DNS zone for that domain name.

创建 DNS 区域:To create the DNS zone:

  1. 在左上角,选择“创建资源” ,然后依次选择“网络”和“DNS 区域”。 At upper left, select Create a resource, then Networking, and then DNS zone.

  2. 在“创建 DNS 区域” 页上,键入或选择以下值:On the Create DNS zone page, type or select the following values:

    • 名称:对于本快速入门示例,键入 contoso.xyz 。Name: Type contoso.xyz for this quickstart example. DNS 区域名称可以是尚未在 Azure DNS 服务器上配置的任何值。The DNS zone name can be any value that is not already configured on the Azure DNS servers. 实际值可以是从域名注册机构购买的域。A real-world value would be a domain that you bought from a domain name registrar.
    • 资源组:选择“新建”,输入 MyResourceGroup,然后选择“确定” 。Resource group: Select Create new, enter MyResourceGroup, and select OK. 资源组名称在 Azure 订阅中必须唯一。The resource group name must be unique within the Azure subscription.
  3. 选择“创建” 。Select Create.

    DNS 区域

创建区域可能需要几分钟。It may take a few minutes to create the zone.

创建 DNS 记录Create a DNS record

在 DNS 区域中为你的域创建 DNS 条目或记录。You create DNS entries or records for your domain inside the DNS zone. 创建一个新的地址记录或“A”记录以将主机名解析为 IPv4 地址。Create a new address record or 'A' record to resolve a host name to an IPv4 address.

创建“A”记录:To create an 'A' record:

  1. 在 Azure 门户中,在“所有资源”下,打开 MyResourceGroup 资源组中的 contoso.xyz DNS 区域 。In the Azure portal, under All resources, open the contoso.xyz DNS zone in the MyResourceGroup resource group. 可以在“按名称筛选”框中输入 contoso.xyz 来更轻松地找到它。 You can enter contoso.xyz in the Filter by name box to find it more easily.

  2. 在“DNS 区域” 页面顶部,选择“+ 记录集” 。At the top of the DNS zone page, select + Record set.

  3. 在“添加记录集” 页上,键入或选择以下值:On the Add record set page, type or select the following values:

    • 名称:键入 www 。Name: Type www. 记录名称是你要解析为指定 IP 地址的主机名。The record name is the host name that you want to resolve to the specified IP address.
    • 类型:选择 A 。“A”记录是最常见的,但是也有其他适用于邮件服务器(“MX”)、IP v6 地址(“AAAA”)等的记录类型。Type: Select A. 'A' records are the most common, but there are other record types for mail servers ('MX'), IP v6 addresses ('AAAA'), and so on.
    • TTL:键入 1 。TTL: Type 1. DNS 请求的存活时间指定 DNS 服务器和客户端可以将响应缓存多长时间。Time-to-live of the DNS request specifies how long DNS servers and clients can cache a response.
    • TTL 单位:选择“小时” 。TTL unit: Select Hours. 这是用于 TTL 值的时间单位。This is the time unit for the TTL value.
    • IP 地址:对于本快速入门示例,键入 10.10.10.10 。IP address: For this quickstart example, type 10.10.10.10. 此值是记录名称解析为的 IP 地址。This value is the IP address the record name resolves to. 在现实场景中,则应输入 Web 服务器的公用 IP 地址。In a real-world scenario, you would enter the public IP address for your web server.

因为本快速入门仅用于快速测试目的,因此不需要在域名注册机构那里配置 Azure DNS 名称服务器。Since this quickstart is just for quick testing purposes, there's no need to configure the Azure DNS name servers at a domain name registrar. 对于现实生产域,你希望 Internet 上的任何人都能够解析主机名,以便连接到你的 Web 服务器或应用。With a real production domain, you'll want anyone on the Internet to resolve the host name to connect to your web server or app. 你将访问域名注册机构来将名称服务器记录替换为 Azure DNS 名称服务器。You'll visit your domain name registrar to replace the name server records with the Azure DNS name servers. 有关详细信息,请参见教程:在 Azure DNS 中托管域For more information, see Tutorial: Host your domain in Azure DNS.

测试名称解析Test the name resolution

现在,你已有一个测试 DNS 区域且其中有一个测试“A”记录,可以使用名为 nslookup 的工具来测试名称解析了。Now that you have a test DNS zone with a test 'A' record, you can test the name resolution with a tool called nslookup.

测试 DNS 名称解析:To test DNS name resolution:

  1. 在 Azure 门户中,在“所有资源”下,打开 MyResourceGroup 资源组中的 contoso.xyz DNS 区域 。In the Azure portal, under All resources, open the contoso.xyz DNS zone in the MyResourceGroup resource group. 可以在“按名称筛选”框中输入 contoso.xyz 来更轻松地找到它。 You can enter contoso.xyz in the Filter by name box to find it more easily.

  2. 在“概述”页面上从名称服务器列表中复制其中一个名称服务器名称。 Copy one of the name server names from the name server list on the Overview page.

    区域

  3. 打开一个命令提示符,并运行以下命令:Open a command prompt, and run the following command:

    nslookup www.contoso.xyz <name server name>
    

    例如:For example:

    nslookup www.contoso.xyz ns1-08.azure-dns.com.
    

    应当会看到类似以下屏幕的内容:You should see something like the following screen:

    nslookup

主机名 www.contoso.xyz 解析为 10.10.10.10,正如你配置的那样 。The host name www.contoso.xyz resolves to 10.10.10.10, just as you configured it. 此结果表明名称解析正常工作。This result verifies that name resolution is working correctly.

清理资源Clean up resources

当不再需要你在本快速入门中创建的资源时,通过删除 MyResourceGroup 资源组将它们删除 。When you no longer need the resources you created in this quickstart, remove them by deleting the MyResourceGroup resource group. 打开 MyResourceGroup 资源组,并选择“删除资源组” 。Open the MyResourceGroup resource group, and select Delete resource group.

后续步骤Next steps