Linux – Azure Linix VM dns-search

azuredomain-name-systemlinuxUbuntu

New to Azure and trying to understand DNS resolution for Linux guests.

My VNET is set to two Windows DNS servers in Azure, when I add a Linux VM they are present and I can ping IP addresses and FQDN's in Azure and on-premise across the VPN.

So at the moment:

ping 1.1.1.1 - works
ping hosta.mydomain.com - works
ping hosta - does not work

Traditionally I get the last to work either via adding dns-search to interfaces or resolv.conf, but these are overwritten by Azure each reboot.

I have found that if I add the line

dns-search mydomain.com

to /etc/network/interfaces.d/50-cloud-init.cfg it works.

I am unsure if this is best practice as I have also seen this article "Azure Linux VM name resolution" suggest it should be done via /etc/dhcp/dhclient.conf.

Is someone able to advise what the best way to do this is, one that survives reboots and preferably survives changes at the Azure portal NIC blade?

Cheers

Best Answer

When you reboot your VM, Azure VM waagent will rest /etc/resolve.conf file, so you will find the file is overwritten.

As S.Walker's link, you could use custom DNS server. You could do it on Azure Portal.

enter image description here

Related Topic