Solved

Changing DNS address of Netowork interface Card using windows script.

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
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…

747 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

13 Experts available now in Live!

Get 1:1 Help Now