Solved

Changing DNS address of Netowork interface Card using windows script.

Posted on 2008-10-20
5
588 Views
Last Modified: 2013-11-09
I am using Windows XP, I need one help. I am having two network card. How to change DNS address (Preferred and alternate)  of both network card using windows script?

Thanks in advance.
0
Comment
Question by:cvinodhkumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:kevin_buchanan
ID: 22764539
I have a script that I use to switch the IP Address, Mask, DNS, and GW on my laptop.  I have to do this because the network schema is different at home and work.

SO...maybe this can help!

You will have to modify the interface names to match your NIC interface names.
changeIP.txt
0
 
LVL 12

Accepted Solution

by:
ibu1 earned 50 total points
ID: 22764697
This is the command
netsh interface ip set dns "local area connection" static 62.215.6.51 primary
Put the above command in a batch file.
Put secondary for secondary dns address.
For second network card the name might be "local area connection 2"
0
 

Author Comment

by:cvinodhkumar
ID: 22764935
ibu1,

Good it works but when i type secondary command prompt shows "secondary is not an acceptable value for register"
0
 
LVL 12

Expert Comment

by:ibu1
ID: 22765314
Sorry, try this command
NETSH INTERFACE IP ADD DNS "LOCAL AREA CONNECTION" 62.215.6.5 INDEX=2
0
 
LVL 1

Expert Comment

by:kevin_buchanan
ID: 22773203
Open a command prompt, run this command:
     netsh interface ip dump

This will give you a script to use to create your own batch file to modify your network config.  I have copied mine in the "code snippet" window.

NOTE:  My wireless interface is called "Wireless - Built In Card" - you will likely be called something else...just look for it and you can modify the code.  
netsh
pushd interface ip
set address name="Wireless - Built In Card" source=static addr=10.0.1.22 mask=255.255.255.0
set address name="Wireless - Built In Card" gateway=10.0.1.1 gwmetric=0
set dns name="Wireless - Built In Card" source=static addr=172.16.1.7 register=PRIMARY
add dns name="Wireless - Built In Card" addr=172.16.1.8 index=2
set wins name="Wireless - Built In Card" source=static addr=none
popd
exit

Open in new window

0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question