Solved

Changing DNS address of Netowork interface Card using windows script.

Posted on 2008-10-20
5
583 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
  • 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

Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a trade show? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

Question has a verified solution.

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

Suggested Solutions

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

910 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now