2

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?

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

2 Answers 2

4

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

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .