Setting Alternate DNS server with NETSH command ???




I can't see a way to use NETSH to set the alternate DNS server
address. I currently use a batch file to reconfigure my work laptop
for use at home thus:-

"netsh interface ip set address "Local Area Connection" static 1
netsh interface ip set dns "Local Area Connection" static"

This works ok, giving me an IP of, subnet,
gateway and DNS

But... my router/DNS box at doesn't always behave with
it's DNS cache so I wanted to add my ISP's one as an alternate, but
fot the life of me can't see how to do this using NETSH.

Any takers ?





Pawan Agarwal \(MSFT\)

Have you tried using netsh command "add dns"

netsh interface ip>add dns

Usage: add dns [name=]<string> [addr=]<IP address> [[index=]<integer>]


Tag Value
name - The name of the interface where DNS servers are added.
addr - The IP address for the DNS server you are adding.
index - Specifies the index (preference) for the specified
DNS server address.

Remarks: Adds a new DNS server IP address to the statically-configured list.
By default, the DNS server is added to the end of the list. If an
index is specified, the DNS server will be placed in that position
in the list, with other servers being moved down to make room.
If DNS servers were previously obtained through DHCP, the new
address will replace the old list.


add dns "Local Area Connection"
add dns "Local Area Connection" index=2


Herb Martin

Follow Pawan's advice but if you are having trouble with the archane syntax
of NetSh, then try this trick:

Manually set the entry (one time); use the NetSh "dump" command to dump
all or part of the settings and redirect the output into a text file.

Edit the text file and use that as the basis of the commands to "script"
back using netsh.exe's "exec" command.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question