How to alter DNS with CMD command?

  • Thread starter Thread starter An
  • Start date Start date
Excuse me for my poor English.
I use a modem dial-up connection,and the DNS server
address is set to Assigned Automatically.But,I have
found,the DNS assigned automatically didn't work.
So I want to temporarily assign another DNS server.
I wonder if there is a CMD command to do this.
 
I use a modem dial-up connection,and the DNS server
address is set to Assigned Automatically.But,I have
found,the DNS assigned automatically didn't work.
So I want to temporarily assign another DNS server.
I wonder if there is a CMD command to do this.

In the dial up settings for your Modem, there is a button
(Advanced or Properties or maybe Advanced Properties
but slightly different on Win2000-XP-etc).

You will see what looks almost like a regular NIC
properties sheet -- select IP and override the DNS
server even before you call.

Manual configuration takes precedence over dynamic.

Many people think that just because they get a DHCP
assigned address they cannot set their DNS server or
Default Gateway.

You can, however, set almost anything except for IP
address and subnet mask; these two parameters must
come from the DHCP server to be a DHCP client at
all.
 
Thanks!
I know how to set the DNS server adress in the GUI interface.
I want to know whether there is any command in command line mode.
 
An said:
Thanks!
I know how to set the DNS server adress in the GUI interface.
I want to know whether there is any command in command line mode.

There are many ways to do it for Windows 2000, XP and 2003. One way is using
the netsh command. You can also search the numerous VB scripts at either
Microsoft's Script Center at www.technet.com, or you can also try some 3rd
party VB scripting sites on the web. One place I've found that has been
helpful is at http://cwashington.netreach.net where many have freely
contributed to the site.


--
Regards,
Ace

Please direct all replies ONLY to the Microsoft public newsgroups
so all can benefit.

This posting is provided "AS-IS" with no warranties or guarantees
and confers no rights.

Ace Fekay, MCSE 2003 & 2000, MCSA 2003 & 2000, MCSE+I, MCT, MVP
Microsoft Windows MVP - Windows Server - Directory Services

Paramount: What's up with taking Enterprise off the air??
Infinite Diversities in Infinite Combinations.
=================================
 
An said:
Thanks!
I know how to set the DNS server adress in the GUI interface.
I want to know whether there is any command in command line mode.

Yes -- in your larger question however you indicated a problem
that can be solved for the interface.

NetSh.exe can do what you seek.

--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
 
Thanks you!
Can you please tell me what command of netsh,
or give me an example?
------------------------------------
 
Can you please tell me what command of netsh,
or give me an example?

I will tell you how to learn netsh... (it's a cool trick)

NetSH.exe has DUMP and EXEC commands for saving
settings and reloading them.

Use the dump ( > to a file) and edit the portions of the
file you care about -- make changes and compare the
changes. Then you can exec the desired portions back
into the machine.

BTW, writing Exec stuff is much easier than getting
the real commands correct.
 
Very interesting! Yes! Use following command:
NETSH DUMP >AA.TXT
This command could dump the settings to file aa.txt.
But the portion about DNS in the file like this:
 
An said:
Very interesting! Yes! Use following command:
NETSH DUMP >AA.TXT
This command could dump the settings to file aa.txt.
But the portion about DNS in the file like this:

This is an RRAS entry I believe -- so unlikely to be
of value to you.

You need the "interface ip" context ('pushd' is just
a "change direct" type command, that also remembers
the last context so that a 'popd' gets you back -- works
at the command line too but few people use it. Sort
of like a History list in your browser.)

Dump your interface IP stuff (or everything) -- change
the interface by hand in the GUI. Dump it again.
Compare the differences or just save that chunk to do
it next time with the command.

It's as simple as saving before (you manually change
something) and after -- next time you can use the Exec
to make those changes in both directions.
 
Manually changed the setting,Dialed up and dumped again,
compared with the last text file with FC command,result:
No difference.
There is also no "interface ip" context in the dump created
text file.
Yet your idea is very good.
 
An said:
Manually changed the setting,Dialed up and dumped again,
compared with the last text file with FC command,result:
No difference.
There is also no "interface ip" context in the dump created
text file.
Yet your idea is very good.


Here are some helpful links for this complicated command:

242468 - How to Use the Netsh.exe Tool and Command-Line Switches:
http://support.microsoft.com/?id=242468

257748 - How to Use the NETSH Command to Change from Static IP Address to
DHCP in Windows 2000:
http://support.microsoft.com/?id=257748

Microsoft Windows XP - Netsh commands for Interface IP:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/netsh.mspx

MS-DOS netsh command help:
http://www.computerhope.com/netsh.htm#04

IP from the Command Prompt:
http://www.petri.co.il/configure_tcp_ip_from_cmd.htm

Chicagotech.net - netsh command:
http://www.chicagotech.net/netsh.htm

Ace
 
I just ran this command on Win2000 (Server), XP, and
Win2003 Server:

netsh interface ip dump

In all cases in dumped a usable IP context.

(I didn't have an dial connection invoked but I am pretty
sure that I have tested that in the past and once established
dial interfaces are practically indistinguishable from a
real NIC in most important ways.)

Ace: Do you use OneNote? I dumped your NetSh links
into my Windows -> Tools -> NetSh page.

Thanks.
 
Thanks a lot!The command was found at last.
The command like this:

NETSH interface ip set dns "Local Area Connection" 202.99.99.99
NETSH interface ip add dns "Local Area Connection" 202.99.99.99

What a long command!
 
Thank you! I nerver heard of OneNote.Is it a useful tool?
I use NETSH DUMP command,that's why there is no the context.
 
Herb said:
I just ran this command on Win2000 (Server), XP, and
Win2003 Server:

netsh interface ip dump

In all cases in dumped a usable IP context.

(I didn't have an dial connection invoked but I am pretty
sure that I have tested that in the past and once established
dial interfaces are practically indistinguishable from a
real NIC in most important ways.)

Ace: Do you use OneNote? I dumped your NetSh links
into my Windows -> Tools -> NetSh page.

Thanks.

No, but I've been thinking about other ways to organize this mess. I have
over 5500 favorites. I use CopyURL to copy/paste the links to text (such as
in a post), but it's cumbersome having that many. Sometimes I think the
system gets hung when parsing them sometimes.

Ace
 
Ace and An:
Ace: Do you use OneNote? I dumped your NetSh links
into my Windows -> Tools -> NetSh page.

Thank you! I nerver heard of OneNote.Is it a useful tool?

Microsoft's newest "Office-like" (not technically part of Office yet),
and in version one they seem to have made a lost of weird UI
decisions but it is on the right track.
No, but I've been thinking about other ways to organize this mess. I have
over 5500 favorites. I use CopyURL to copy/paste the links to text (such as
in a post), but it's cumbersome having that many. Sometimes I think the
system gets hung when parsing them sometimes.

OneNote is useful. It seems to be better than my other methods
after only a couple of weeks -- it is not a total replacement for
favorites, but does help with organizing

I have mainly used just standard favorites, text files, Excel,
and even Outlook "draft" emails. This seems to beat all of
the above.

5500 links sounds like a lot -- I probably have that many but
they aren't very well organized. (I have been collecting them
since before IE3.)

--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]

"Ace Fekay [MVP]"
 
Herb said:
OneNote is useful. It seems to be better than my other methods
after only a couple of weeks -- it is not a total replacement for
favorites, but does help with organizing

I have mainly used just standard favorites, text files, Excel,
and even Outlook "draft" emails. This seems to beat all of
the above.

5500 links sounds like a lot -- I probably have that many but
they aren't very well organized. (I have been collecting them
since before IE3.)

I may give it a try. I have a copy thru my MSDN subscription. The only thing
I don't like its that it's another app running in the background. Obi
mentioned one awhile back that integrates with IE, but I can't remember what
it's called. I'm building a new dual Xeon with a Raid5 1.2 terabytes of
storage (need it to store my classroom Ghost images and be able to run
multiple VPCs without taxing the system too much). I may go with OneNote
when I get that completed.

In the meantime, I'll just keep chugging along with this old flathead V8
(Bonnie and Clyde's choice)...
 
Thank you,Ace and Herb,for your answer to my question.
I have found it pretty good to "talk" to you.Now there
is a new question here.
It is clear that one of the key point of using NETSH
command to set DNS server is to know the interface name.
This question can be solved by using the command bellow:
NETSH interface ip dump
It works well to use this command in my broadband connection
computer.But when this command was used in my dial connection
computer,it returned an error message(translated into English):

"Eerror when get the configuration from interface
{93856A9A-802A-427A-A2FF-777CF57974FE}"

What the interface name should be?
 
Back
Top