I am trying to get all the A records for some domains. The best way I have found is to use https://www.whatsmydns.net and the nexcess tool. The issue is that it is very slow to copy paste them and sort through all the trash. I tried some scraping but the javascript means it breaks half the time.

Another idea was to just run the dns queries from my server but I am unsure how effective that would be since most dns servers are anycast.

Is it possible to write a script that did "nslookup google.com" and kept going through a list of dns servers then outputted just the IP addresses from the A records to a file named google.com.txt or something and removed any duplicates.

Thanks in advance!

  • 1
    are you comfortable missing some round-robin A records? It sounds like you're wanting a zone transfer ("get all the A records for some domains"), which has been locked down for ... some time now. – Jeff Schaller Aug 24 '15 at 17:04

The dig(1) or host(1) commands can be automated to lookup A records:

% for d in example.com example.org; do dig +short A $d; done
% for d in example.com example.org; do host -t A $d; done                   
example.com has address
example.org has address

As a script, one way would be:

$ cat domlu
# accepts list of domains one per line on standard input, emits unique
# A records for said domains (assuming no errors, etc).
( while read domain; do
  dig +short A "$domain"
done ) | sort -u
$ cat hl
$ chmod +x domlu 
$ ./domlu < hl
  • How can I make it iterate through a list of dns servers I create? This is exactly what I was looking for thx! – user130040 Aug 24 '15 at 17:23
  • Put the command above into a script. Then source another file with your list of servers set as a variable. So your script would start with something like: . ./servers.list for d in $servers; do ... Then in the servers.list file put in something like: servers="example.com example.org" (hmm...doesn't look like comments support block formatting. Someone may have to help me clarify this, or just add it to the answer.) – Rick Chatham Aug 24 '15 at 18:17

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.