Setting Alternate DNS server with NETSH command ???

P

pcmangler2000

Hi,

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
192.168.1.4 255.255.255.0 192.168.1.1 1
netsh interface ip set dns "Local Area Connection" static 192.168.1.1"

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

But... my router/DNS box at 192.168.1.1 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 ?

Cheers,

Kev.
 
P

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

Parameters:

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.

Examples:

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

-Pawan
 
H

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"
them
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

Top