Generate BIND reverse DNS entries
I sometimes have to create rDNS entries for a particular server with a bunch of IPs -- and doing it manually isn't very much fun. The following script quickly creates entries that can be pasted into your zone file, or outputted to another file.
#!/bin/bash
# Script to generate Bind reverse DNS entries
# If no arguments, it will ask for each parameter,
# otherwise, you can you simply call it like:
# script "my description" hostname.com. startIP endIP
if [ ! "$1" ]
then
echo -n "Enter description: "
read desc
echo -n "Enter hostname: "
read host
echo -n "Enter start IP: "
read startip
echo -n "Enter end IP: "
read endip
else
desc=$1
host=$2
startip=$3
endip=$4
fi
count=$startip
echo "; $desc"
while [ $count -le $endip ]
do
printf "%d\t%s\t%s\t%s\n" $count IN PTR $host
count=$((count+1))
done
Example:
$ genrdns.sh "my server" myserver.com 82 90
; my server
82 IN PTR myserver.com
83 IN PTR myserver.com
84 IN PTR myserver.com