• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1144
  • Last Modified:

Startup Script to Chagne DNS Entries

Hi,

I will give a bried description of my Network setup and then ask my question.

One Primay Domain Controller (2003) and one Additional Domain Controller (2003) at Data Center. Both have Active Directory and DNS on them.

There are around 3000 clients (at different locations - Windows XP) which use the PDC and ADC as primary and secondary DNS in their DNS entries. To decrease the network traffice, we have commissioned 18 different ADCs (named NAP servers) at different Locations with AD and DNS.

These 3000 clients (all windows XP) roughly fall under these 18 NAP servers @ 200 clients per NAP.

Now, My Problem:

I need to update the DNS entries of the corresponding 200 clients under each NAP to have the Primary DNS IP as the NAP IP and then Secondary and Tirtiary DNS IPs as the PDC and ADC at the Data Center. So, the client PC would reach the NAP servers to resolve DNS queries.

Please help me with the starup script that would help me push through Group Policy and get the DNS entries updated. A script which will run at start up that will add the three DNS entries (NAP server - PDC -ADC) whith out much manual intervention.

If any one can give me the exact code for the script and clear instructions on how to implement it, I would be really greatful.

Thank you
 

0
pradeepkaravadi
Asked:
pradeepkaravadi
1 Solution
 
Rob WilliamsCommented:
You could write a simple batch file with the lines below. To deploy it, create a GPO for the OU containing the computers you wish to affect. It would need to be run as a startup script rather than a logon script. The policy location is:
Computer configuration | windows settings | scripts | startup

netsh interface ip set dns name = "Local Area Connection" source = static addr = 10.10.10.101
netsh interface ip add dns name = "Local Area Connection" addr = 10.10.20.102
netsh interface ip add dns name = "Local Area Connection" addr = 10.10.20.103

The two catches with this is the NIC name has to be known. The default is of course "Local Area Connection", and the current DNS configuration has to be such that the GPO can be read and applied.
0
 
aflockhartCommented:
Do your client computers  get their IP information automatically from DHCP ? If so, change the DNS Server entries on your DHCP server, and the clients will get it automatically
0
 
pradeepkaravadiAuthor Commented:
Client computers are NOT in DHCP. All have static IPs
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mkbeanCommented:
Log on to a machine with an account that has administrative permissions over the computers you want to modify.  Copy the code snippet below into a .vbs file and place it along with two files, one called servers.txt (with your computer names) and the other changedns.log (blank) into the same directory.  Run the vbs and it will change all the DNS settings to what ever you want...just make sure to change that option in the .vbs file.  It is the top two lines.

Thanks,
Brian
strNewDNSServer1 = "10.127.65.112"
strNewDNSServer2 = "10.127.65.113"
 
arrDNSServers = Array(strNewDNSServer1, strNewDNSServer2)
 
On Error Resume Next
 
Const ForReading = 1
Const ForWriting = 2
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("systems.txt", ForReading)
Set objLogFile = objFSO.OpenTextFile("changeDNS.log", ForWriting)
 
Do Until objTextFile.AtEndOfStream 
    strComputer = trim(objTextFile.Readline)
wscript.echo " "
wscript.echo "__________________________________________"
wscript.echo " "
wscript.echo "Setting new DNS servers on " & strComputer & ":"
wscript.echo " "
objLogFile.Writeline " "
objLogFile.Writeline "___________________________________________"
objLogFile.Writeline " "
objLogFile.Writeline "Setting new DNS servers on " & strComputer & ":"
objLogFile.Writeline " "
 
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Set colNetCards = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
 
For Each objNetCard in colNetCards
	If Not IsNull(objNetCard.DNSServerSearchOrder) then
		DNSServer = " "
		For i = 0 to 1
			DNSServer = DNSServer & objNetCard.DNSServerSearchOrder(i) & " > "
		Next
		wscript.echo "DNS before: " & DNSServer
		objLogFile.Writeline "DNS before: " & DNSServer
	        objNetCard.SetDNSServerSearchOrder(arrDNSServers)
	End If
Next
wscript.sleep 2500
Set colNetCards = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
 
For Each objNetCard in colNetCards
	If Not IsNull(objNetCard.DNSServerSearchOrder) then
		DNSServer = " "
		For i = 0 to 1
			DNSServer = DNSServer & objNetCard.DNSServerSearchOrder(i) & " > "
		Next
		wscript.echo "DNS after:  " & DNSServer
		objLogFile.Writeline "DNS after:  " & DNSServer
	End If
Next
 
Loop ' GO GET Next line from file
 
objTextFile.Close
objLogFile.Close

Open in new window

0
 
pradeepkaravadiAuthor Commented:
Hi Rob, can you explain what you meant by "and the current DNS configuration has to be such that the GPO can be read and applied"
0
 
Rob WilliamsCommented:
For a GPO to be applied the PC must be able to authenticate to the domain and access your DNS server. If you are changing DNS servers one must be currently 'reachable' with their current DNS settings, in order to apply any GPO, including the new GPO with the new DNS server IP's.

With that many PC's you are not using DHCP? To bad as that would make life much simpler as pradeepkarav& suggested

Also, just noticing you are using NAP servers. How are the users connecting? Any chance by VPN?
0
 
AmericomCommented:
You may consider use DHCP as your way of managing 3000 with static IPs is a very very unusual implementation.

As the above experts mentioned, you cannot obtain the GPO without first getting the IP configured. With static IP, you will have problem and continue to face problem with today's technology. You will have tons of work to manage daily. What about user that use VPN, do they still configured with static and alternate IP etc, that would alone would be more works..not to mentioned wired-auto configure and wireless etc..

Even client reservation is better than static at least you have more control with the TCP/IP setting via DHCP and can easily be managed.
0
 
pradeepkaravadiAuthor Commented:
DHCP was not in the Design of the Deliverables for this project. So I guess I might have to stick to my setup mentioned above. But, these 18 NAP servers I think will reduce the network load and help in better management.

@Robwil - We are not using VPN
0
 
Rob WilliamsCommented:
That must be a nightmare managing and documenting 3000 clients with static IP's :-)
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now