Pages

DNS Bulk ADD

use ease:--

For /F %a in (list.txt) do addaptr.bat %a

list.txt sample input is

addaptr.BAT DNSSERVERNAME COMPUTERSNAMETOBEADD.DOMAINNAME.COM IPADDRESS

addaptr.bat 10.0.0.20 QTEST.PADDYMADDY.COM 10.0.0.23

 

script:-

::  addaptr.bat
::
::  Purpose:         Add an A and PTR record using dnscmd.exe
::
::  Usage:           addaptr dnsserver fqdn ipadd
::
::                     dnsserver  DNS server's ip, hostname or "." if the
::                                DNS service is running on local machine
::                     fqdn       FQDN of the host you want the records
::                                to be added for (hostname.mydomain.com)
::                     ipadd      ip address of the host
:: __________________________________________________________________
::
@Echo Off
SetLocal

Set dnsserver=%1
Set fqdn=%2
Set ipadd=%3

If Not Defined ipadd (
  Echo Add an A and PTR record using dnscmd.exe
  Echo.
  Echo %~n0 dnsserver fqdn ipadd
  Echo.
  Echo   dnsserver  DNS server's ip address, hostname, or "." if the DNS
  Echo              service is running on local machine.
  Echo   fqdn       FQDN of the host you want the records to be added for
  Echo              ^(hostname.mydomain.com^)
  Echo   ipadd      ip address of the host
  Goto End
)

For /F "Tokens=1,* Delims=." %%A In ("%fqdn%") Do (
  Set hostname=%%A
  Set fzone=%%B
)
For /F "Tokens=1-4 Delims=." %%A In ("%ipadd%") Do (
  Set rzone=%%C.%%B.%%A.in-addr.arpa
  Set okt4=%%D
)

:: Add PTR record
DnsCmd %dnsserver% /RecordAdd %rzone% %okt4% PTR %fqdn%

:: Add A record
DnsCmd %dnsserver% /RecordAdd %fzone% %hostname% A %ipadd%
Echo Done.
Goto End

:Err
Type %TEMP%.\%~n0.log
Pause

:End
If Exist %TEMP%.\%~n0.log Del %TEMP%.\%~n0.log
EndLocal</pre>

0 comments:

Post a Comment