The settings are located at: Network and Sharing Center > Wi-Fi > Properties > IPV4 > Properties

I need to regularly switch between 'obtain DNS server address automatically' and 'use the following DNS addresses'

How could I toggle this using command prompt?

  • A quick Google suggests you can look in the registry, but you can also use PowerShell... – Kinnectus Feb 6 at 11:32

Assuming we are talking about Windows 10...

In powershell to set the DNS:

Set-DnsClientServerAddress -InterfaceIndex 12 -ServerAddresses ("","")

And to revert back to the ones configured by DHCP:

Set-DnsClientServerAddress -InterfaceIndex 12 -ResetServerAddresses

You have to find out what InterfaceIndex you have to specify. List your adapters with the powershell cmdlet ...


… and choose which one is appropriate


The cmd.exe version:

To set your DNS server:

netsh interface ip set dns "Local Area Connection" static

To add a second one:

netsh interface ip add dns "Local Area Connection" index=2

To revert back to the DNS server(s) provided by DHCP:

netsh interface ip set dns "Local Area Connection" dhcp

(Replace "Local Area Connection" with the name of your interface, if needed.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.