0

Alright,

I want to do a bulk reverse DNS query to a specific nameserver.

Currently, after searching here and Google, I got it to work for 1 entry at the time with the following command: dig @NAMESERVER -x 10.10.10.10 +short

This returns exactly what I want. But If I want to do this for multiple IP addresses, it fails. What I did was to make a list of 2 IP addresses to test.

I'm trying to use he following command: dig @NAMESERVER -x -f dnsquery.txt +short

This does not show any result, what am I doing wrong?

The input files has 2 lines, each with 1 IP address:
10.10.10.10
10.10.10.11

  • You'll probably want to covert the a.b.c.d to the reverse d.c.b.a.in-addr.arpa and then do PTR ... lookups, or use a loop around dig that calls -x a.b.c.d for each IP. – thrig Nov 23 '16 at 0:08
  • Ho do I do a loop, sorry newbie here.... – frankguthrie Nov 23 '16 at 7:34
1

As thrig mentioned, you could loop the dig call.

You can use for example this little bash script ans save it in a file called e.g. bulkreverse.sh:

#!/bin/bash
filename='ip_in.txt' # name of file with IPs to handle
nameserver='8.8.8.8' # nameserver to query

for ip in `cat $filename`
do
echo 'Handling reverse DNS for $ip'
dig @$nameserver -x $ip +short
done

The variable filename specifies the name of the file with the list of IP addresses (like you example, oen IP per line). nameserver is the nameserver to query.

If you saved the script in a file called bulkreverse.sh you need to make it executable by running

chmod +x bulkreverse.sh

After that you can execute it with

./bulkreverse.sh

I hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.