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.

 

The Author — Mitch Tulloch

Mitch Tulloch is a widely recognized expert on Windows administration, networking, and security. He has been repeatedly awarded Most Valuable Professional (MVP) status by Microsoft for his outstanding contributions in supporting users who deploy and use Microsoft platforms, products and solutions. Mitch has published over two hundred articles on different IT websites and magazines, and he has written or contributed to almost two dozen books and is lead author for the Windows 7 Resource Kit from Microsoft Press. For more information, see www.mtit.com .

Latest Contributions

Featured Links