Project Objective:
We have multiple Windows DNS servers that need a forwarder configured for a specific domain.

Problem to be solved:
This is normally a setting that needs to be configured by hand on each DNS server.

@echo off

rem #***********************************************************************
rem # "Add-DNS-Forwarders.bat"
rem #
rem # Written by Aaron Wurthmann (aaron (AT) wurthmann (DOT) com)
rem # If you edit please keep my name as an original author and
rem # keep me apprised of the changes, see email address above.
rem # This code may not be used for commercial purposes.
rem # You the executor,runner,user accept all liability.
rem # This code comes with ABSOLUTELY NO WARRANTY.
rem # You may redistribute copies of the code under the terms of the GPL v2.
rem # -----------------------------------------------------------------------
rem # 2010.11.02 ver FINAL
rem #
rem # Summary:
rem # Creates conditional DNS forwards for domains.
rem # Be sure to adjust your settings below as needed.
rem #************************************************************************

rem    DNS Servers to contact/run against
set DNSserver1=192.168.1.100
set DNSserver2=192.168.1.101

rem    Conditional Zone to Forward For
set Zone=domain.ext

rem    DNS Forwards to contact for Conditional Zone seperated with a single space
set Forwarders=192.168.2.100 192.168.2.101

rem    Main
FOR /F "usebackq tokens=2 delims==" %%i IN (`set DNSserver`) DO (
    dnscmd %%i /zoneadd %Zone% /forwarder %Forwarders%
)
Be Sociable, Share!