Simple BASH script to mass query reverse DNS PTR records for a subnet

Wrote this up the other day to do a quick reverse PTR query of some internal subnets. Possibly handy if you don’t have quick access to another tool like dnsrecon.


#Populate subnets.txt with the first three sections of the target subnet IP, one subnet per line eg

subnets=$(cat './subnets.txt');
for subnet in $subnets
        for ip in $subnet.{1..255}
            dig -x $ip | sed -n '/ANSWER SECTION:/,/Query time:/p' | sed '/ANSWER SECTION/d' | sed '/Query time:/d' | sed '/./!d'
#echo $ip


I’ve since found the useful python based dnsrecon which seems to work really well for this also:

./ -t rvl -r

Leave a Reply

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