Solved

Changing DNS address of Netowork interface Card using windows script.

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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…

776 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