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

how to create zones automatically.

I backed up primary and secondary zones from one DNS server (server1) and restored them to another DNS server (server2).
Now I need the zones to show up in the DNS server console (server2). Do I have to create them manually or there is a way to make them show up automatically. They are over a hundred zones.

Thanks
0
jskfan
Asked:
jskfan
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
suggestionstickCommented:
what OS, DNS version
0
 
Chris DentPowerShell DeveloperCommented:

Both MS DNS? I have scripts that can be used to create Secondary servers from a Primary.

Chris
0
 
omarfaridCommented:
you said you took backup! did you change any info in the restored files?
0
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.

 
jskfanAuthor Commented:
they are both MS DNS servers on W2003 standard edition
0
 
omarfaridCommented:
you may import the files
0
 
Chris DentPowerShell DeveloperCommented:

This script generates a batch file called SetupZones.bat which uses DNSCMD to make the changes below.

On the Primary Server:

1. Adds an NS Record for the Secondary Server
2. Enables Zone Transfers to all servers in the NS List
3. Enables Notify

On the Secondary Server:

1. Adds a secondary zone

There's an optional second step which would be used if the Primary is being removed, but we shouldn't need that here.

Chris
Const PRI_DNS_SERVER = "<PrimaryDNS>"
Const PRI_DNS_SERVER_IP = "<IP>"
Const SEC_DNS_SERVER = "<SecondaryDNS>"
Const SEC_DNS_SERVER_FQDN = "<SecondaryDNSName>"
 
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("dnscmd " & PRI_DNS_SERVER & " /EnumZones /Primary /Forward")
Set objStdOut = objScriptExec.StdOut
 
Set objDomains = CreateObject("Scripting.Dictionary")
	
booStartList = False
Do Until objStdOut.AtEndOfStream
	strOut = Trim(objStdOut.ReadLine)
 
	If strOut <> "" Then
		If InStr(1, strOut, "Command completed", VbTextCompare) > 0 Then
			booStartList = False
		End If
 
		If booStartList = True Then
			arrTemp = Split(strOut, " ")
			If Not objDomains.Exists(arrTemp(0)) Then
				objDomains.Add arrTemp(0), ""
			End If
		End If
 
		If InStr(1, strOut, "Zone name", VbTextCompare) > 0 Then
			booStartList = True
		End If
	End If
Loop
 
Set objStdOut = Nothing
Set objScriptExec = Nothing
 
Set objScriptExec = objShell.Exec("dnscmd " & SEC_DNS_SERVER & " /EnumZones /Secondary /Forward")
Set objStdOut = objScriptExec.StdOut
 
booStartList = False
Do Until objStdOut.AtEndOfStream
	strOut = Trim(objStdOut.ReadLine)
 
	If strOut <> "" Then
		If InStr(1, strOut, "Command completed", VbTextCompare) > 0 Then
			booStartList = False
		End If
 
		If booStartList = True Then
			arrTemp = Split(strOut, " ")
			If objDomains.Exists(arrTemp(0)) Then
				objDomains.Remove arrTemp(0), ""
			End If
		End If
 
		If InStr(1, strOut, "Zone name", VbTextCompare) > 0 Then
			booStartList = True
		End If
	End If
Loop
 
Set objStdOut = Nothing
Set objScriptExec = Nothing
Set objShell = Nothing
 
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.OpenTextFile("SetupZones.bat", 2, True, 0)
 
If objDomains.Count > 0 Then
	For Each strDomain in objDomains
		objFile.WriteLine
		objFile.WriteLine "Rem Commands for " & strDomain
		objFile.WriteLine "dnscmd " & PRI_DNS_SERVER & " /RecordAdd " &_
			strDomain & " @ NS " & SEC_DNS_SERVER_FQDN
		objFile.WriteLine "dnscmd " & PRI_DNS_SERVER &_
			" /ZoneResetSecondaries " & strDomain & " /SecureNs /Notify"
		objFile.WriteLine "dnscmd " & SEC_DNS_SERVER & " /ZoneAdd " &_
			strDomain & " /Secondary " & PRI_DNS_SERVER_IP
                ' This command makes the Secondary Zone Primary in migration scenarios
		' objFile.WriteLine dnscmd " & SEC_DNS_SERVER &_
		'	" /ZoneResetType /Primary /file " & strDomain & ".dns"
		objFile.WriteLine
	Next
End If
 
Set objFile = Nothing
Set objFileSystem = Nothing

Open in new window

0
 
jskfanAuthor Commented:
I used dnscmd /zoneadd.
I had to do some stuff manually though
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now