Azure Virtual Network Custom DNS Server

5.8k views Asked by At

I created a virtual network and put 2 VMs in one subnet. But they were not able to ping each other using their hostnames. I need a DNS Server implemented so that hostnames in the subnet can be resolved to IP addresses. How do I do that? Any help will be appreciated. :)

1

There are 1 answers

0
jangelfdez On BEST ANSWER

the simplest scenario is to add your hostnames and ips to your localhost file if you are on Windows or you /etc/resolv.conf if you are on Linux. Deploy your VMs with fixed private IPs to avoid changes if they are rebooted or shutdown.

However, if the scenario is more complex with more than two machines, the best way is to deploy a DNS Server inside your VNET. The steps are the following ones:

  1. First you need to add to your virtual network a DNS. You can do it through the management portal in the section NETWORKS > {Your Network Name} > CONFIGURE > dns servers. Fill it with a name and an IP.
  2. Deploy a new VM inside the Virtual Network and set it's IP to the same IP you have defined inside the portal. You can do it through PowerShell (https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-private-ip/#how-to-add-a-static-internal-ip-to-an-existing-vm)
  3. Configure your DNS server with the records for the VMs and set the forwarders if you want to be able to resolve names outside the virtual network.
  4. You can reboot your virtual machines to get the new configuration through DHCP.

An example: http://www.ytechie.com/2013/06/setting-up-a-dns-server-in-azure-iaasvms/