Script to creat PTR zone from zone file

big bond bondarets at gmail.com
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 isc.org>

> 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:

#!/bin/bash
NET=192.168.111
HOST=example.com
LIMIT=254
    for ((i=1;a<=LIMIT;i++))
        do
            IP=`echo $NET.$i`
            ARPA=`host $NET.$a | awk '{print $5}'`
            FIRSTOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
-f1`
            SECOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
-f2`
            THIRDOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
-f3`
            LASTOCT=`echo $IP $ARPA | grep NX | awk '{print $1}' | cut -d .
-f4`
            PTR=`echo host$LASTOCT.$THIRDOCT.$SECOCT.$FIRSTOCT.$HOST | grep
-v 't\.'`
            echo $LASTOCT.$THIRDOCT.$SECOCT.$FIRSTOCT.in-addr.arpa.    IN
 PTR    $PTR.  | egrep -v '^\.'
        done

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: <https://lists.isc.org/pipermail/bind-users/attachments/20101101/52e0a888/attachment.html>


More information about the bind-users mailing list