Men & Mice Men & Mice Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Migrating a DNS Server by Zonetransfer  XML
Forum Index -> Scripting and Customizing
Author Message
Carsten Strotmann
Men & Mice Staff
[Avatar]

Joined: 26/07/2007 13:08:39
Messages: 159
Location: Germany
Offline

The Men & Mice Suite can import RFC 1035 style zonesfiles using either the GUI Console or the Command Line Interface.

This can be used to import data from any other DNS Server that supports standard zonetransfers (like the old QuickDNS 1.x - 3.x on MacOS classic).

The script below takes two arguments: a name or IP Address of a DNS Server being authoritative for the zones, and a text file with a list of domain names, one name in each line.

File Format for Domain list
Code:
 example.org
 test.example
 example.net
 subdomain.example.com
 


Code:
 #!/opt/local/bin/rexx
 /* Rexx */
 
 PARSE ARG server infile
 
 SAY server
 SAY infile
 
 rc = Stream(infile, 'C','OPEN READ')
 
 u = 0
 domains. = ""
 domains.0 = u
 
 DO WHILE Lines(infile) > 0
         line = LineIn(infile)
         domain = Strip(line)
         u = u + 1
         domains.u = domain
         domains.0 = u	
 END
 
 rc = Stream(infile, 'C', 'CLOSE')
 
 DO x = 1 to domains.0
 	domain = domains.x
 	SAY "transferring domain" domain
               filename = domain ||'txt'
               cmd = 'dig @' || server 'axfr' domain '>' filename
 	SAY cmd
 	cmd
 	rc = Stream(filename, 'C', 'OPEN READ')
 	y = 0
 	zonefile. = ""
 	zonefile.0 = y
 	soa = 0
         DO WHILE Lines(filename) > 0
 		line = LineIn(filename)
 		IF Pos("SOA", line) > 0 THEN DO
 			IF soa = 0 THEN 
 				soa = 1
 			ELSE
 				line = ""
 			
 		END
 		f = Pos(';', line)
 		IF f = 0 THEN DO
  			y = y + 1
 			zonefile.y = line
 			zonefile.0 = y
 		END
 	END
 	rc = Stream(filename, 'C', 'CLOSE')
 	rc = Stream(filename, 'C', 'OPEN WRITE REPLACE')
 	DO z = 1 TO zonefile.0
 		rc = LineOut(filename, zonefile.z)
 	END
 	rc = Stream(filename, 'C', 'CLOSE')
 
 END
 
 RETURN
 


The script is written in the programming language REXX. An open source implementation of REXX can be found at http://regina-raxx.sf.net



----
Men & Mice Support Team
support@menandmice.com
 
Forum Index -> Scripting and Customizing
Go to:   
Powered by JForum 2.1.7 © JForum Team