Change DNS Servers RRS feed

  • Question

  • Is it possible to change the configured DNS Server settings for a Virtual Network after it has been created and is being used by machines.

    Through the preview portal I understand this is not possible, but was wondering if this is something which could be done with PowerShell?

    The use case for this is after deploying an AD server to azure, so that machines in Azure no longer need to rely on the VPN link to be active in order for them to make DNS queries i.e. to our on site DNS servers.

    Thursday, August 9, 2012 2:03 PM


All replies

  • Hi Garry,

    The intent is that ultimately you will be able to change DNS settings on a Virtual Network that is already in use (has VMs deployed to it) but currently that is not the case, and I don't have an ETA for that capability.

    However right now you should be able to achieve this by setting DNS settings with PowerShell at the deployment level, not on the Virtual Network.

    The sample in Step 6 here gives you an idea of how to configure that.


    Thursday, August 9, 2012 8:25 PM
  • Is there any update on an ETA for the ability to change the DNS settings at the Virtual Network level?

    My scenario is very similar. We had an on-premesis dns server die, and we decided to replace it with an Azure VM. We would now like to remove the IP of the old DNS server and replace it with the IP of our new Azure VM DNS server.

    Does step 6 above only apply to creating a new VM with different DNS settings than those configured on the Virtual Network, or will it also work for changing the DNS settings of an existing VM? If it will work for updating an existing VM, can anyone provide a sample script that might be a little closer to that than the one in step 6?

    Thanks in advance!

    Tuesday, October 23, 2012 9:16 PM
  • We also need this functionality.    Now that I have things working I don't want to have to delete and re-create just because of one simple DNS ip address.

    Please consider rolling this out soon... 

    Tuesday, October 30, 2012 1:07 AM
  • Thank you for the feedback, gnomehole.
    Tuesday, October 30, 2012 11:34 PM
  • Has there been any update on this?  I am in a current need to be able to do this.
    Tuesday, March 5, 2013 8:44 PM
  • I too hope this gets functionality gets added soon, I desperately need switch the DNS Servers.
    • Edited by KenBTate Thursday, March 7, 2013 8:18 PM
    Thursday, March 7, 2013 1:55 PM
  • I have figured out a temporary workaround for this scenario.

    It is actually ok to manually set the dns servers on the virtual machines in the azure network.  You do not want to change any ip or subnet information but manually changing dns servers is fine.

    On my network I manually changed all the dns servers on all virtual machines so that they included the ones normally given out via dhcp plus my new one I need to add.

    Once they give us this functionality we can change it at the dhcp level in the network config but until now just manually update the dns servers on your vm.

    Thursday, March 7, 2013 2:23 PM
  • Jason,

    I too tried that, and my guess is when the DHCP lease renews it reverts back to Automatically assigned DNS from the DHCP server.  I also statically assigned the DNS address, but after complaints from users that they could not log on, the DNS reverted back to automatically assign DNS.  This is a HUGE issue for me right now.

    Thursday, March 7, 2013 8:13 PM
  • Yeah we are running to that also.  Services on the vms will just stop working, we remote into the servers and the static dns settings have been reverted back to dhcp controlled which means it cant contact our azure AD/DNS controller.

    Seriously thinking about writing a windows service that does nothing but set dns settings on the adapters every hour so that it keeps them correct

    Wednesday, March 27, 2013 1:38 PM
  • Jason,

    There's a better way, even today. Simply deploy your VM with PowerShell and set DNS on the Cloud Service. That way the DNS setting will persist through reboots and moves and other events.

    Also, we are in the process of deploying functionality to be able to change DNS on the VNet. It will be available soon. When it is available you will be able to change DNS on the VNet and simply reboot your VM to get the new setting. Check back in a month or so.


    Wednesday, March 27, 2013 2:41 PM
  • Does this work if the vms are already deployed?
    Wednesday, March 27, 2013 2:56 PM
  • Hi Jason,

    You can't change the DNS of a Cloud Service when VMs are deployed to it. However, you can remove the VMs and redeploy with the same VHD. This is faster than creating a new VM from an image because when you re-use your VHD it is no longer sysprepped and the first boot is a normal one.

    Best regards,


    Thursday, March 28, 2013 1:22 AM
  • Just now Azure Virtual Networks as announced for General Availability.  I just checked and the ability to change DNS is still not there.  Does this seem like a problem to anyone else that General Availability doesn't have this key change that has been promised to be coming?
    Tuesday, April 16, 2013 1:09 PM
  • Jason,

    I agree there are a lot of networking issues still and I was surprised to hear they went GA without resolving them.  I actually have a very similar post about this same issue and I was able to use Steve's method above to remove my VM from the cloud service and redeploy it with the proper DNS using powershell.  To me this is a very temporary workaround and I can only hope they put out new networking features. 

    Tuesday, April 16, 2013 3:07 PM
  • Tim,

    It also depends on what services you are running whether or not you can do that.  If you have an AD controller on a vm from what I understand its much much more tricky to just re-use the vhd on a new vm instance due to security id's that are generated for it and such.  Also if mission critical services are deployed you have limited ability to redeploy.

    I know that since it was preview its been advised not to put mission critical services on azure vm's but now that its GA if people don't know about this issue they could end up putting themselves into a bind now that its ok from Microsoft to deploy production environments.

    Tuesday, April 16, 2013 3:20 PM
  • Jason, 

    When I said remove I didn't mean sysprep and capture and then deploy that image, just remove the VM and re-deploy the same VHD in a new cloud service.  My understanding is that the cloud service is what provides the IP address and DNS information.  

    Here is what I did, I am still working on how to better automate the process but here is the general idea: 

    # Variable Setup
    $ServiceName = "myCloudService"
    $VmName = "myVM1"
    $DnsAzure1 = New-AzureDns -Name "myDNSVM1" -IPAddress ""
    $DnsAzure2 = New-AzureDns -Name "myDNSVM2" -IPAddress ""
    $DnsOnPrem1 = New-AzureDns -Name "myOnPrem1" -IPAddress ""
    $DnsOnPrem2 = New-AzureDns -Name "myOnPrem2" -IPAddress ""
    $AffinityGroup = "myAffinityGroup"
    $VirtualNetwork = "myVirtualNetwork"

    # Export the VM(s) configuration in the cloud Service 
    Export-AzureVM -ServiceName $ServiceName  -Name $VmName  -Path 'c:\azure\myVM1.xml'
    # Remove VMs in the cloud service
    Remove-AzureVM -ServiceName $ServiceName  -Name $VmName 

    #I manually went to the portal and removed the cloud service but I think the powershell command is Remove-AzureDeployment

    #Create the Cloud Service by deploying the first VM and specifying the DNS information 
    Import-AzureVM -Path 'c:\azure\myVM1.xml' | New-AzureVM -ServiceName $ServiceName -AffinityGroup $AffinityGroup -DnsSettings $DnsAzure1,$DnsAzure2,$DnsOnPrem1,$DnsOnPrem2 -VNetName $VirtualNetwork

    #If there multiple VMs in the same cloud service, deploy them by excluding everything after ServiceName (Import-AzureVM -Path 'c:\azure\myVMx.xml' | New-AzureVM -ServiceName $ServiceName)

    By doing that, you are still using the same VHD of the VM you created but the DNS information will now be updated to what you specified when you create the cloud service.  I have tested and it persists with restarts, what I still want to test is when you remove the cloud service and recreate it with the same name does the local IP address remain the same.

    The main issue is you now have to create every VM with powershell to have the proper DNS and you can no longer use the portal to create VMs.

    Here is a great blog on exporting, removing, recreating .. but without specifying the DNS to solve this post's issue.

    - Tim 

    • Proposed as answer by Tim Benham Tuesday, April 16, 2013 4:45 PM
    Tuesday, April 16, 2013 4:45 PM
  • Hey Tim, yeah I understand.  From what I understand with ActiveDirectory though, deploying the same vhd on a new vm (just new cpu id's and such, no new sysprepped system) can still cause problems and requires more steps than just booting it up.  Its a risk we don't want to take right now.
    Wednesday, April 17, 2013 1:29 PM
  • Hi Guys

    I’ve come across this post as I have this exact issue.  I did hear of MS bringing out some PowerShell commands to give admins the ability to change DNS servers on VMs? 

    Please tell me I’m not dreaming as this would be a great Xmas pressie from Microsoft if it’s true?

    If not then looks like I will have to redeploy my DC.  Thanks


    Monday, December 23, 2013 1:55 PM
  • Hi Spuddist,

    You can now change the DNS servers for your virtual network if they were automatically assigned. Once changed a reboot of the machine will apply the new dns servers for the machine.

    If however you specified the DNS servers manually at creation time for the VM you will need to update them with PowerShell, I believe they are set on the Cloud Service Object. I do not know if you can remove them and make them use the default VNet DNS settings.

    Tuesday, January 7, 2014 9:30 AM