DNS records creator

Back around here. Quick post of a small script to create A and PTR dns records.

Input file. First column is the IP and second column is the fqdn. We call this file hosts.txt athletic.abc.com deportivo.abc.com drac1.abc.com

Script below:


while read line; do
        IP=`echo $line | awk '{print $1}'`
        HOST=`echo $line | awk '{print $2}'`
        PTR=`echo "${IP}" | awk -F\. '{print $4"."$3"."$2"."$1".in-addr.arpa."}'`
        echo "${HOST}. IN A ${IP}"
        echo "${PTR} IN PTR ${HOST}."
done < hosts.txt


me@server:/tmp$ bash dnsconverter.sh
athletic.abc.com. IN A IN PTR athletic.abc.com.
deportivo.abc.com. IN A IN PTR deportivo.abc.com.
drac1.abc.com. IN A IN PTR drac1.abc.com.

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Geographica  –  What City Do You See?