Using Private DNS Zones for Custom Domains in Azure …
What is Azure Private DNS Zone ?
Private DNS zone resolves the DNS queries within virtual network. The DNS records in the DNS zones are not resolvable over the Internet and that is why it is called Private. This is quite handy when you want to use your own domain name within virtual network and that also without any complicated DNS solution.
Typical Flow for using Private DNS Zone
- Create Private DNS Zone with required domain name ( e.g. dev.com )
- Create Virtual Network
- Create link between Private DNS zone and virtual network
Steps 1 and 2 may be done in any order.
Demo Setup
The demo setup contains following.
- dev.com private DNS zone
- dev vnet
- vm1 and vm2 in dev vnet
Step — Test the Setup
- Connect to vm1 in dev vnet
2. Try to resolve the DNS names for virtual machines from dev vnet .
nslookup vm1.dev.com
nslookup vm2.dev.com
This does not resolve the domain name !
In order for private DNS zone to be effective it has to be linked with dev vnet.
3. Create Virtual Network link between dev.com private DNS zone and dev vnet
4. Try to resolve vm1.dev.com and vm2.dev.com again.
This time it works as it is associated with dev VNET !
If we look at the dev.com private DNS zone then we should see the DNS entries for vm1 and vm2 as shown below. This is added by Azure for us. VMs in the VNET are automatically registered with Private DNS zone based on ‘Auto Registration Enabled’ setting for creating virtual network link.
Thus Azure Private DNS zone simplifies the DNS management without building your custom DNS solution.There are additional use cases which can be setup by using Private DNS zones such as to resolve multiple domain names (test.com , prod.com ) from multiple networks and integrating it with custom DNS solution, however that is for another post !