Script to creat PTR zone from zone file

Alan Clegg aclegg at isc.org
Sat Oct 30 11:04:21 UTC 2010


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 some script that may help you... :)
> 
> Example of input file to be generated:
> 
> InstitutTeknologiBandung    192.168.0.154   router2.id    192.168.0.153 
> router1.id
> local   192.168.0.157   ITB-local.id   192.168.0.158  local-ITB.id
> 
> Script that I did for this file:
> 
> #!/bin/sh
> 
> LOCALLIST="localfile"
> 
> echo "Start Node Script\n"
> rm revlocal
>     # Cut The Line
>     if [ -e $LOCALLIST ]; then
> 
>       while read line
>     do
>       row1="$(echo $line | cut -d " " -f2 | cut -d "." -f4)"
>       row2="$(echo $line | cut -d " " -f3 | cut -d "." -f1)"
>       row3="$(echo $line | cut -d " " -f4 | cut -d "." -f4)"
>       row4="$(echo $line | cut -d " " -f5 | cut -d "." -f1)"
> 
>     echo "$row1    IN  PTR        node.$row2.net\n$row3    IN  PTR       
> node.$row4.net"
>     echo "$row1    IN  PTR        node.$row2.net\n$row3    IN  PTR       
> node.$row4.net" >> revlocal
> 
>     done < $LOCALLIST
> 
>    fi
> echo "\nEnd Node Script"
> 
> 
> Then, the output will be:
> 
> 154  IN  PTR  router2.net
> 153  IN  PTR  router1.net
> 157  IN  PTR  ITB-local.net
> 158  IN  PTR  local-ITB.net

Instead of the series of "cuts" above (which will be VERY difficult with
IPv6 addresses), you may want to look at the "arpaname" executable that
comes with bind.

aclegg at baremetal:~$ arpaname 192.168.1.1
1.1.168.192.IN-ADDR.ARPA

aclegg at baremetal:~$ arpaname  2001:470:a037::53
3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.7.3.0.A.0.7.4.0.1.0.0.2.IP6.ARPA

AlanC

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <https://lists.isc.org/pipermail/bind-users/attachments/20101030/54ef1776/attachment.bin>


More information about the bind-users mailing list