Configuring a secondary DNS server from the command line

by Mitch Tulloch [Published on 3 April 2012 / Last Updated on 3 April 2012]

How to configuring a secondary DNS server on a client computer from the command line.

You can use the dnsclient context of the netsh command to configure a primary DNS server like this:

netsh dnsclient set dnsservers name="Local Area Connection" source=static address=10.0.0.1validate=no

But how do you use netsh dnsclient to configure a secondary DNS server?

You can't. You need to use this command instead:

netsh interface ip add dns name= addr= index=

The above command can be used to add a new DNS server to the statically-configured list on the client, and by default each time you run the command it adds the DNS server to the end of the list. If the optional index= parameter is used, the newly configured DNS server will be placed in the position specified while the other DNS servers will be moved down to make room for the new server in the DNS list on the client.  For example, you could configure primary and secondary DNS servers using these two commands:

netsh interface ip add dns name="Local Area Connection" addr=10.0.0.1

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

Mitch Tulloch is a seven-time recipient of the Microsoft Most Valuable Professional (MVP) award and widely recognized expert on Windows administration, deployment and virtualization. For more tips by Mitch you can follow him on Twitter or friend him on Facebook.

 

Featured Links