A request came up in a newsgroup for a script which would automate the creation of a primary zone on one DNS server, enable zone transfers, and then configure a secondary zone on another DNS server.  A first generation release of a script was posted today.  If there is interest for a more flexible script which has more options for things like where the zone is stored, what the zone security is, etc, then I will gladly revise the script.

For now, it’s fully functional and a link to the very simple CMD code can be found here:

::CB5 Solutions, LLC
::http://www.cbfive.com/blog/page/Primary-and-Secondary-Zone-Creation.aspx
::scripts@cbfive.com
::Version 1.0

::===================================================================
::    Disclaimer:
::    The sample scripts are not supported under any CB5 standard support program or service.
::    The sample scripts are provided AS IS without warranty of any kind. CB5 Solutions further disclaims
::    all implied warranties including, without limitation, any implied warranties of merchantability
::    or of fitness for a particular purpose. The entire risk arising out of the use or performance
::    of the sample scripts and documentation remains with you. In no event shall CB5 Solutions, its
::    authors, or anyone else involved in the creation, production, or delivery of the scripts be
::    liable for any damages whatsoever (including, without limitation, damages for loss of
::    business profits, business interruption, loss of business information, or other pecuniary
::    loss) arising out of the use of or inability to use the sample scripts or documentation,
::    even if CB5 Solutions has been advised of the possibility of such damages.
::==================================================================

::==================================================================
::  This script will create two zones:
::
::    - Primary, DS-integrated zone stored in the DomainDNS application partition
::        - Secure only dynamic updates will be enabled
::        - Aging will be enabled with the default values of 7 days for the refresh and
::        the no-refresh interval
::        - Secure zone transfer enabled with only the IP address provided allowed for
::        zone transfer
::      - Notification is enabled for the server to which transfers will be made
::
::    - Secondary zone
::        - Configured to update from primary master configured above
::        - A zone file will be created after the name of the zone at %systemroot%system32dns
::
::  At the command-line, you must type the command file name and then the value for each of
::the three arguments.  The value of the arguments are as follows:
::
::  %1 - IP address of the DNS server where you want to create the primary zone (eg 10.10.17.10)
::  %2 - zone name (eg newsgroup.com)
::  %3 - IP address of the DNS server where you want to create the secondary zone (eg 10.10.17.250)
::
::=========       Syntax       =========
::createPrimaryAndSecondaryZone.cmd %1 %2 %3
::
::=========    Sample Usage    =========
::createPrimaryAndSecondaryZone.cmd 10.10.17.10 newsgroup.com 10.10.17.250
::
::==================================================================

cd
dnscmd %1 /zoneadd %2 /DsPrimary /dp /domain
dnscmd %1 /config %2 /allowupdate 2
dnscmd %1 /config %2 /aging 1
dnscmd %1 /zoneresetsecondaries %2 /SecureList %3 /NotifyList %3
dnscmd %3 /zoneadd %2 /secondary %1 /file %2.dns

This sample code can be used to create primary and secondary zones.  The primary zone will be created as an AD-integrated zone, configured for secure updates and aging with the default values.  The zone will allow zone transfers only to the server that is provided as an argument at the command line.  The secondary zone will be created to pull from the server where the AD-integrated zone was created.  The secondary zone will have a zone file with the same name created at %systemroot%system32dns, by default.

Simply copy the text below and paste it to notepad.  Save the file as createPrimaryAndSecondaryZone.cmd.  This can be run from any workstation that has DNSCMD.  DNSCMD is part of the Support Tools and the latest version as of this writing can be found here.

If you have any other requests please feel free to post them in the comments or email them to scripts@cbfive.com and I’ll be glad to attempt to add them.

NOTE:  Please remember that this is sample code and while it has been tested multiple times under a variety of conditions, no two environments are exactly alike.  It is important that you test all code first to make sure that it is functional as you desire it to be for your environment.