DNS settings Script

Posted on 2009-02-10
Medium Priority
Last Modified: 2012-05-06
I am looking for a script to use with group policy to set the Primary, Secondary, and Advance DNS settings DNS entry for all my servers with Static IP addresses.  I am getting ready to change some IP addresses of my DNS servers and did not want to do it manually on all servers.  Does anyone know of a script that will accomplish this?
Question by:Serenea Carpenter

Accepted Solution

dkumar82 earned 1000 total points
ID: 23605464
You can perform using NETSH command. Below is few example

You can write a simple batch file
eg at \\pcname xx:xx netsh ... or Using Run as

This changes the IP address and Default Gateway:
netsh int ip set address "local area connection" static {} {} 1

This changes DNS:
netsh int ip set dns "local area connection" static {} primary
You will want to change the values between the curly braces, but do not use the curly braces when you run the command.
To change the interface back to DHCP (get IP automatically) use this command:
netsh int ip set address "local area connection" dhcp

netsh int ip set dns "local area connection" dhcp

Author Comment

by:Serenea Carpenter
ID: 23611207
That will work if i can make some changes to the DNS one.  I dont want to run this on every server individually.  That would defeat the purpose of having a script.  Can I use wildcards in the IP address?  Like 192.168.*.*?  Also I suppose for the secondary i would just add a second line to this that ends with secondary?  And I do have four entries i want to add so would would i end with for the two others i want to add in the DNS advance page?  Thanks for your help.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

839 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