教程:配置表示 Azure 公共 IP 地址的别名记录Tutorial: Configure an alias record to refer to an Azure public IP address

本教程介绍如何执行下列操作:In this tutorial, you learn how to:

  • 创建网络基础结构。Create a network infrastructure.
  • 使用公共 IP 创建 Web 服务器虚拟机。Create a web server virtual machine with a public IP.
  • 创建指向公共 IP 的别名记录。Create an alias record that points to the public IP.
  • 测试别名记录。Test the alias record.

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

先决条件Prerequisites

必须具有可用于在 Azure DNS 中托管以供测试的域名。You must have a domain name available that you can host in Azure DNS to test with. 必须能够完全控制此域。You must have full control of this domain. 完全控制包括能够为域设置名称服务器 (NS) 记录。Full control includes the ability to set the name server (NS) records for the domain.

有关在 Azure DNS 中托管域的说明,请参阅教程:在 Azure DNS 中托管域For instructions to host your domain in Azure DNS, see Tutorial: Host your domain in Azure DNS.

本教程中使用的示例域为 contoso.com,但请使用自己的域名。The example domain used for this tutorial is contoso.com, but use your own domain name.

创建网络基础结构Create the network infrastructure

首先,创建要放置 Web 服务器的虚拟网络和子网。First, create a virtual network and a subnet to place your web servers in.

  1. https://portal.azure.cn 中登录 Azure 门户。Sign in to the Azure portal at https://portal.azure.cn.
  2. 在门户的左上角,选择“创建资源”。 In the upper left in the portal, select Create a resource. 在搜索框中输入“资源组”,然后创建名为 RG-DNS-Alias-pip 的资源组 。Enter resource group in the search box, and create a resource group named RG-DNS-Alias-pip.
  3. 选择“创建资源” > “网络” > “虚拟网络”。 Select Create a resource > Networking > Virtual network.
  4. 创建名为“VNet-Server”的虚拟网络。 Create a virtual network named VNet-Server. 将其放在 RG-DNS-Alias-pip 资源组中,然后将子网命名为 SN-WebPlace it in the RG-DNS-Alias-pip resource group, and name the subnet SN-Web.

创建 Web 服务器虚拟机Create a web server virtual machine

  1. 选择“创建资源” > “Windows Server 2016 VM” 。Select Create a resource > Windows Server 2016 VM.
  2. 输入名称“Web-01” ,然后将 VM 放在“RG-DNS-Alias-TM” 资源组中。Enter Web-01 for the name, and place the VM in the RG-DNS-Alias-TM resource group. 输入用户名和密码,然后选择“确定”。 Enter a username and password, and select OK.
  3. 对于“大小”,请选择具有 8 GB RAM 的 SKU 。For Size, select an SKU with 8-GB RAM.
  4. 对于“设置” ,请选择“VNet-Servers” 虚拟网络和“SN-Web” 子网。For Settings, select the VNet-Servers virtual network and the SN-Web subnet. 对于公共入站端口,请选择“HTTP” > “HTTPS” > “RDP (3389)”,然后选择“确定” 。For public inbound ports, select HTTP > HTTPS > RDP (3389), and then select OK.
  5. 在“摘要” 页中,选择“创建” 。On the Summary page, select Create.

此过程需要几分钟才能完成。This procedure takes a few minutes to finish. 虚拟机会有一个附加的 NIC,该 NIC 将有一个名为 Web-01-ip 的基本动态公共 IP。The virtual machine will have an attached NIC, which will have a basic dynamic public IP called Web-01-ip. 每次重启虚拟机时,此公共 IP 都会更改。The public IP will change every time the virtual machine is restarted.

安装 IISInstall IIS

Web-01 上安装 IISInstall IIS on Web-01.

  1. 连接到 Web-01 并登录 。Connect to Web-01, and sign in.
  2. 在“服务器管理器”仪表板上,选择“添加角色和功能”。 On the Server Manager dashboard, select Add roles and features.
  3. 选择“下一步”三次。 Select Next three times. 在“服务器角色”页上,选择“Web 服务器(IIS)”。 On the Server Roles page, select Web Server (IIS).
  4. 选择“添加功能”,然后选择“下一步” 。Select Add Features, and then select Next.
  5. 选择“下一步”四次,然后选择“安装” 。Select Next four times, and then select Install. 此过程需要几分钟才能完成。This procedure takes a few minutes to finish.
  6. 安装完成后,选择“关闭” 。After the installation finishes, select Close.
  7. 打开 Web 浏览器。Open a web browser. 浏览到“localhost” 以验证是否显示默认 IIS 网页。Browse to localhost to verify that the default IIS web page appears.

创建别名记录Create an alias record

创建指向公共 IP 地址的别名记录。Create an alias record that points to the public IP address.

  1. 选择 Azure DNS 区域以打开该区域。Select your Azure DNS zone to open the zone.
  2. 选择“记录集”。 Select Record set.
  3. 在“名称” 文本框中选择“web01” 。In the Name text box, select web01.
  4. 将“类型”保留为 A 记录 。Leave the Type as an A record.
  5. 选择“别名记录集”复选框 。Select the Alias Record Set check box.
  6. 选择“选择 Azure 服务” ,然后选择“Web-01-ip” 公共 IP 地址。Select Choose Azure service, and then select the Web-01-ip public IP address.

测试别名记录Test the alias record

  1. 在“RG-DNS-Alias-pip” 资源组中,选择“Web-01” 虚拟机。In the RG-DNS-Alias-pip resource group, select the Web-01 virtual machine. 记录公共 IP 地址。Note the public IP address.
  2. 在 Web 浏览器中,浏览到 Web01-01 虚拟机的完全限定域名。From a web browser, browse to the fully qualified domain name for the Web01-01 virtual machine. 例如,web01.contoso.comAn example is web01.contoso.com. 此时会看到 IIS 默认网页。You now see the IIS default web page.
  3. 关闭 Web 浏览器。Close the web browser.
  4. 停止“Web-01” 虚拟机,然后将其重新启动。Stop the Web-01 virtual machine, and then restart it.
  5. 虚拟机重启后,记录虚拟机的新公共 IP 地址。After the virtual machine restarts, note the new public IP address for the virtual machine.
  6. 打开新的浏览器。Open a new browser. 再次浏览到 Web01-01 虚拟机的完全限定域名。Browse again to the fully qualified domain name for the Web01-01 virtual machine. 例如,web01.contoso.comAn example is web01.contoso.com.

此过程成功是因为你使用了指向公共 IP 地址资源的别名记录,而非标准的 A 记录。This procedure succeeds because you used an alias record to point to the public IP address resource, not a standard A record.

清理资源Clean up resources

不再需要为本教程创建的资源时,请删除 RG-DNS-Alias-pip 资源组。When you no longer need the resources created for this tutorial, delete the RG-DNS-Alias-pip resource group.

后续步骤Next steps

在本教程中,你已创建表示 Azure 公共 IP 地址的别名记录。In this tutorial, you created an alias record to refer to an Azure public IP address. 若要详细了解 Azure DNS 和 Web 应用,请继续阅读有关 Web 应用的教程。To learn about Azure DNS and web apps, continue with the tutorial for web apps.