DNS settings Script

Posted on 2009-02-10
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
    LVL 8

    Accepted Solution

    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
    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This article describes how to set permissions to allow a limited-permissions user to start and stop a particular System Service.   It is always best to give users only the permissions that they need to perform their job, so tweaking particular permi…
    Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    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). …

    760 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

    9 Experts available now in Live!

    Get 1:1 Help Now