0

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
1

Assuming we are talking about Windows 10...

In powershell to set the DNS:

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

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 ...

Get-NetAdapter

… and choose which one is appropriate

1

The cmd.exe version:

To set your DNS server:

netsh interface ip set dns "Local Area Connection" static 10.0.0.1

To add a second one:

netsh interface ip add dns "Local Area Connection" 10.0.0.2 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.