Resetting the DNS server list to static in Azure

The SharePoint 2013 development environment in Azure that i maintain contains a fully fledged AD/DNS infrastructure. To keep things lean, i did not want to maintain a separate infrastructure VM and just combine the roles. However, every time the machine is restarted, the IP interface settings needs to be adjusted. I need to ensure that the Azure provided DNS server needs to be come secondary DNS server in the list while loopback address stays as primary. I have not fully automated this just yet, but here is the command-line methods to get it done.

netsh interface ip "Ethernet 8" add dnsserver 127.0.0.1 primary
netsh interface ip add dnsserver "Ethernet 8" 100.112.12.40 index=2

To update the DNS services forwarder to the new server ip address:

import-module DnsServer
Set-DnsServerForwarder -IPAddress 100.112.12.40
Advertisement