Script to creat PTR zone from zone file

Sukman sukman at tf.itb.ac.id
Sat Oct 30 05:42:58 UTC 2010


> 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

----------------------------------------------------
Best Regards :)

Suksmandhira H
Engineering Physics - ITB





More information about the bind-users mailing list