This article will be about Private DNS Zones in Azure which is in continuation to my previous article on DNS Zones in Azure. I recommend you to read that article before you proceed with this to have a better understanding. Let’s look at what private DNS Zones are, how to create them in Azure, and the purpose of using Private DNS Zones.
What is DNS?
DNS Stands for Domain Name System and is used to resolve names (like google.com, facebook.com, etc.) to IP Addresses. To keep it simple Domain Name system is like a Telephone directory where peoples phone numbers are mapped to the individuals just that telephone directory has numbers and names of individuals, Domain Name System is the directory of the Internet which stores domain names like google.com and facebook.com and IP addresses so that the end-users can load the webpages.
Now talking about Domain Names, Domain names should be unique. Why do we need a Domain Name? Say, for instance, starting tomorrow if Google asks you to use an IP address instead of google.com to use their search engine. Will you like it? I personally don’t. It’s not user-friendly and difficult to remember for end-users. As an admin, if I need to change IP for some reason in the future, the IP needs to be shared with everyone all over again, which is not a right/efficient way of doing it. Hence we use DNS as a solution to let users use hostnames instead of IP Addresses.
What are Private DNS Zones?
Private DNS Zones is a service provided by Microsoft in Azure Portal. Unlike DNS Zones, Private DNS Zones do not require internet. These are used at the Intranet level over Virtual Networks. It helps you resolve the local DNS. The purpose of using Private DNS Zones is to use hostnames instead of IP addresses of all the VM’s present in the environment. Unlike DNS Zones, which uses public domain, we use a local domain in Private DNS Zones, which does not require registration with domain registrars.
Steps to create Private DNS Zone
- Login to Azure Portal and type Private DNS Zones in search bar at the top or you can select it from the list of resources shown in the dashboard.
- Click Create.
- Enter all the required details and click “Review + Create“.
Linking Virtual Networks with Private DNS Zone
Once the Private DNS Zone is created, you need to map your Virtual networks with the Private DNS Zone so that the VM’s linked to the Virtual network can resolve their hostname to IP address. Once you map the Virtual network with the Private DNS Zone, VM’s will automatically register with the DNS. Let us take a look and see how to map Virtual networks with the Private DNS Zone.
- Go-to the private DNS Zone you created and click on Virtual Network links on the left side pane as shown below.
- Click on Add at the top from the list of options.
NOTE! I already have a virtual network created with Virtual machines linked to it. I recommend you do the same before linking the Virtual network (next step) with DNS Zone.
- Provide all the required details like name for the link, select the subscription, Virtual Network, Check Enable Auto registration and click on OK.
Enable Auto Registration
This option lets the Virtual machines automatically register with DNS, thereby creating an ‘A’ record within the DNS Zone. If you do not enable this option, you need to add the ‘A’ record of all the Virtual machines individually, one after another manually. This option will automatically add Virtual machines, which will be linked to the mapped Virtual network in the future.
- Once the virtual network is mapped successfully, you should see the ‘A’ record of those Virtual Machines in the private DNS Zone as shown below.
Once all the steps mentioned above are performed as-it-is, you should resolve the hostnames of your Virtual machines with IP addresses.