Script to creat PTR zone from zone file

big bond bondarets at
Mon Nov 1 10:37:47 UTC 2010

Sorry, first message was sent not for the list but to Alan only. (by the
way, why "reply" button does not send message to list by default?)

2010/10/30 Alan Clegg <aclegg at>

> On 10/30/2010 1:42 AM, Sukman wrote:
> >> Looking to write a script to create the PTR records..
> >> Not much on the Web..
> >

I had same problem recently and i have written a script:

    for ((i=1;a<=LIMIT;i++))
            IP=`echo $NET.$i`
            ARPA=`host $NET.$a | awk '{print $5}'`
            FIRSTOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
            SECOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
            THIRDOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
            LASTOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
            PTR=`echo host$LASTOCT.$THIRDOCT.$SECOCT.$FIRSTOCT.$HOST | grep
-v 't\.'`
            echo $LASTOCT.$THIRDOCT.$SECOCT.$    IN
 PTR    $PTR.  | egrep -v '^\.'

My problem was to "fill the gaps" in my PTR records, because some of them
have already been created by hand before. So my script lookups for existing
PTRs and generetes the missing ones by pattern. Script is not much elegant
and clean (same my English is), but it works.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the bind-users mailing list