none
Using DNSCMD to bulk create PTR records RRS feed

  • Question

  • I am try to bulk create PTR records using DNSCMD syntax as noted below. Its failing due the error listed.

    c:\for /f "tokens=1-7 delims=," %G IN (list.txt) do dnscmd DNSBOX /recordadd %f.%e.%d.in-addr.arpa %g ptr %a.%b.%c

    Command failed:  DNS_ERROR_ZONE_DOES_NOT_EXIST     9601  (00002581)

    The list.txt contains the hostname,IP with no header.

    Any idea what correction this syntax needs ? Shouldn't the PTR records try to go in their respective reverse zones as they are there.

    Thanks,
    Wednesday, December 3, 2008 9:22 PM

Answers

  •  

    Hi,

     

    For the question about developing scripts, I’d like to suggest that you post it in the MSDN forum. The support professionals there are better qualified to assist you.

     

    MSDN forum

    http://forums.microsoft.com/MSDN

     

    For your reference, here are some dnscmd examples:

     

    To add a new zone:

    Dnscmd /zoneadd 0.168.192.in-addr.arpa /dsprimary /dp /domain

     

    To add a PTR record:

    Dnscmd /recordadd 0.168.192.in-addr.arpa 5 PTR test.joson.local

    Hope it helps.

    Monday, December 8, 2008 9:19 AM
    Moderator

All replies

  • Hi Scharique,

    The problem is with the for statement and with the list.txt file.
    Save the following in a cmd file:
    for /F "tokens=1-7,* delims=," %%a in (list.txt) DO (
    dnscmd DNSBOX /recordadd %%f.%%e.%%d.in-addr.arpa %%g ptr %%a.%%b.%%c
    )
    An example of the list.txt file format is this:
    pcname,test,com,10,1,2,86
    .
    .
    Executing the cmd will do what you want.

    Have a nice day! The Masterplan - MCSE,MCITP-EA http://winmasterplan.blogspot.com
    Thursday, December 4, 2008 8:43 AM
  • Thank you TM. After modifying the format of my txt file. I saved the command in a batch file and ran. It scrolls/splashes thru with no results.

    Here is how the batch file looks like:

    for /F "tokens=1-8,* delims=," %%a in (list.txt) DO (
    dnscmd testdc02 /recordadd %%f.%%e.%%d.in-addr.arpa %%g ptr %%a.%%b.%%c
    )


    Here is the list.txt looks like:


    testserver1,na,test,int,10,1,1,2
    testserver2,na,test,int,10,1,1,3

    Thursday, December 4, 2008 5:51 PM
  • Hi Scharique,

    So, the FQDN of a workstation in your domain is like this: testserver1.na.test.int
    In this case, you should also modify the batch file like this:

    for /F "tokens=1-8,* delims=," %%a in (list.txt) DO (
    dnscmd testdc02 /recordadd %%g.%%f.%%e.in-addr.arpa %%h ptr %%a.%%b.%%c.%%d
    )

    Have a nice day! The Masterplan - MCSE,MCITP-EA http://winmasterplan.blogspot.com
    Friday, December 5, 2008 6:13 PM
  • have you tried this command ? it does not seem to work for me, I have modified the batch file with the syntax you edited based on my csv format.

    it is in this format

    testserver1,na,test,int,10,1,1,2
    testserver2,na,test,int,10,1,1,3

    batch command splashes by and does not actually add the records, i have made sure that the 10.1.1.x zone exists,

    additionally, is there a way to add the zoneadd command in this command if the zone already doesn't exist.

    Thanks,
    Friday, December 5, 2008 8:25 PM
  •  

    Hi,

     

    For the question about developing scripts, I’d like to suggest that you post it in the MSDN forum. The support professionals there are better qualified to assist you.

     

    MSDN forum

    http://forums.microsoft.com/MSDN

     

    For your reference, here are some dnscmd examples:

     

    To add a new zone:

    Dnscmd /zoneadd 0.168.192.in-addr.arpa /dsprimary /dp /domain

     

    To add a PTR record:

    Dnscmd /recordadd 0.168.192.in-addr.arpa 5 PTR test.joson.local

    Hope it helps.

    Monday, December 8, 2008 9:19 AM
    Moderator