Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have over 250 domain names with one registrar which, due to years of organisational neglect, point to various different servers hosting the websites.

I've been asked to clean this up. sigh

To start off, I want to get a list of each domain name and their DNS A records to see which server they're pointing to. Does anybody know how I can go about this?

share|improve this question

closed as not a real question by mulaz, EEAA, John Gardeniers, Ward, HopelessN00b Sep 25 '12 at 23:54

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Put all the domains in a txt file, loop over them in your favorite scripting language... Done... (If you want more info, we need some more info. OS, Language... –  Bart De Vos Sep 24 '12 at 15:49
    
We might be able to give you some shortcuts if you name the registrar. But any way you go, this is going to be one big unsightly mess. –  Michael Hampton Sep 24 '12 at 21:14

3 Answers 3

up vote 1 down vote accepted

Here's how I'd do it in PowerShell using a text file with one domain per line.

Get-Content domains.txt | %{
  new-object -type PSObject -property @{
    Domain=$_
    IPAddr=[System.Net.Dns]::GetHostAddresses($_)
  }
}

Which outputs something like:

Domain                IPAddr
------                ------
www.google.com        {2001:4860:4001:803::1011, 74.125.224.145, 74.125.224....
www.yahoo.com         {2001:4998:c:401::c:9101, 2001:4998:c:401::c:9102, 200...
www.flickr.com        {216.115.107.206, 67.195.141.201, 67.195.141.200, 98.1...
www.serverfault.com   {64.34.119.12}
www.stackexchange.com {64.34.119.12}

Here's how I'd do it in Perl with the same text file.

perl -MSocket -nE 'chomp; say $_, " ", inet_ntoa "".gethostbyname $_;' domains.txt

Which outputs something like:

www.google.com 74.125.141.103
www.yahoo.com 72.30.38.140
www.flickr.com 216.115.107.206
www.serverfault.com 64.34.119.12
www.stackexchange.com 64.34.119.12
share|improve this answer
    
I used the PowerShell solution above and it produced the effect I wanted. Thanks, Starfish. However, the script hangs after about a dozen domains, do you know of any reason why this would be? Edit: Scrap that, if I hit return, the script continues. –  bobble14988 Sep 25 '12 at 9:01

An even easier answer is to get the DNS records from the registrar to see where they're pointing. Most good bulk registrars have an export function just for this kind of thing. Now, if they're all being hosted off site, you might need to resort to the code to get A records for them. But seeing that DNS resolution has been delegated to ns1.hosting.com will be a big clue to help you locate the appropriate hosting company and start working on obtaining credentials.

share|improve this answer

In Bash:

Put your domains, one per line, in domains.txt.

for domain in $( cat domains.txt ); do host -ta $domain; done

That'll print something like:

stackoverflow.com has address 64.34.119.12
serverfault.com has address 64.34.119.12
share|improve this answer

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