Quickstart: Create an Azure private DNS zone using the Azure portal
This quickstart walks you through the steps to create your first private DNS zone and record using the Azure portal.
A DNS zone is used to host the DNS records for a particular domain. To start hosting your domain in Azure DNS, you need to create a DNS zone for that domain name. Each DNS record for your domain is then created inside this DNS zone. To publish a private DNS zone to your virtual network, you specify the list of virtual networks that are allowed to resolve records within the zone. These are called linked virtual networks. When autoregistration is enabled, Azure DNS also updates the zone records whenever a virtual machine is created, changes its IP address, or is deleted.
Important
When you create a private DNS zone, Azure stores the zone data as a global resource. This means that the private zone is not dependent on a single VNet or region. You can link the same private zone to multiple VNets in different regions. If service is interrupted in one VNet, your private zone is still available. For more information, see Azure Private DNS zone resiliency.
In this article, two VMs are used in a single VNet linked to your private DNS zone with autoregistration enabled. The setup is summarized in the following figure.
Prerequisites
If you don’t have an Azure subscription, create a free account before you begin.
If you prefer, you can complete this quickstart using Azure PowerShell or Azure CLI.
Create a private DNS zone
The following example creates a DNS zone called private.contoso.com in a resource group called MyAzureResourceGroup.
A DNS zone contains the DNS entries for a domain. To start hosting your domain in Azure DNS, you create a DNS zone for that domain name.
On the portal search bar, type private dns zones in the search text box and press Enter.
Select Private DNS zone.
Select Create private dns zone.
On the Create Private DNS zone page, type or select the following values:
- Resource group: Select Create new, enter MyAzureResourceGroup, and select OK. The resource group name must be unique within the Azure subscription.
- Name: Type private.contoso.com for this example.
For Resource group location, select West Central US.
Select Review + Create.
Select Create.
It may take a few minutes to create the zone.
Virtual network and parameters
In this section you'll need to replace the following parameters in the steps with the information below:
Parameter | Value |
---|---|
<resource-group-name> | MyAzureResourceGroup (Select existing resource group) |
<virtual-network-name> | MyAzureVNet |
<region-name> | West Central US |
<IPv4-address-space> | 10.2.0.0/16 |
<subnet-name> | MyAzureSubnet |
<subnet-address-range> | 10.2.0.0/24 |
Create the virtual network and subnet
In this section, you'll create a virtual network and subnet.
On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.
In Create virtual network, enter or select this information in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select Create new, enter <resource-group-name>, then select OK, or select an existing <resource-group-name> based on parameters. Instance details Name Enter <virtual-network-name> Region Select <region-name> Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
In the IP Addresses tab, enter this information:
Setting Value IPv4 address space Enter <IPv4-address-space> Under Subnet name, select the word default.
In Edit subnet, enter this information:
Setting Value Subnet name Enter <subnet-name> Subnet address range Enter <subnet-address-range> Select Save.
Select the Review + create tab or select the Review + create button.
Select Create.
Link the virtual network
To link the private DNS zone to a virtual network, you create a virtual network link.
- Open the MyAzureResourceGroup resource group and select the private.contoso.com private zone.
- On the left pane, select Virtual network links.
- Select Add.
- Type myLink for the Link name.
- For Virtual network, select myAzureVNet.
- Select the Enable auto registration check box.
- Select OK.
Create the test virtual machines
Now, create two virtual machines so you can test your private DNS zone:
- On the portal page upper left, select Create a resource, and then select Windows Server 2016 Datacenter.
- Select MyAzureResourceGroup for the resource group.
- Type myVM01 - for the name of the virtual machine.
- Select West Central US for the Region.
- Enter a name for the administrator user name.
- Enter a password and confirm the password.
- For Public inbound ports, select Allow selected ports, and then select RDP (3389) for Select inbound ports.
- Accept the other defaults for the page and then click Next: Disks >.
- Accept the defaults on the Disks page, then click Next: Networking >.
- Make sure that myAzureVNet is selected for the virtual network.
- Accept the other defaults for the page, and then click Next: Management >.
- For Boot diagnostics, select Disable, accept the other defaults, and then select Review + create.
- Review the settings and then click Create.
Repeat these steps and create another virtual machine named myVM02.
It will take a few minutes for both virtual machines to complete.
Create an additional DNS record
The following example creates a record with the relative name db in the DNS Zone private.contoso.com, in resource group MyAzureResourceGroup. The fully qualified name of the record set is db.private.contoso.com. The record type is "A", with the IP address of myVM01.
- Open the MyAzureResourceGroup resource group and select the private.contoso.com private zone.
- Select + Record set.
- For Name, type db.
- For IP Address, type the IP address you see for myVM01. This should be auto registered when the virtual machine started.
- Select OK.
Test the private zone
Now you can test the name resolution for your private.contoso.com private zone.
Configure VMs to allow inbound ICMP
You can use the ping command to test name resolution. So, configure the firewall on both virtual machines to allow inbound ICMP packets.
Connect to myVM01, and open a Windows PowerShell window with administrator privileges.
Run the following command:
New-NetFirewallRule –DisplayName "Allow ICMPv4-In" –Protocol ICMPv4
Repeat for myVM02.
Ping the VMs by name
- From the myVM02 Windows PowerShell command prompt, ping myVM01 using the automatically registered host name:
You should see output that looks similar to this:ping myVM01.private.contoso.com
PS C:\> ping myvm01.private.contoso.com Pinging myvm01.private.contoso.com [10.2.0.4] with 32 bytes of data: Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Reply from 10.2.0.4: bytes=32 time=1ms TTL=128 Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Ping statistics for 10.2.0.4: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms PS C:\>
- Now ping the db name you created previously:
You should see output that looks similar to this:ping db.private.contoso.com
PS C:\> ping db.private.contoso.com Pinging db.private.contoso.com [10.2.0.4] with 32 bytes of data: Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Reply from 10.2.0.4: bytes=32 time<1ms TTL=128 Ping statistics for 10.2.0.4: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms PS C:\>
Clean up resources
When no longer needed, delete the MyAzureResourceGroup resource group to delete the resources created in this quickstart.
Next steps
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for