Get all DNS records associated with an IP



The following code returns the IPv4 address of a given alias or host:

The below code returns the HostName (CName) and aliases of an IP:

I’d therefore expect anything which returns an IP on GetHostAddresses to be listed under the HostName or Aliases of a call to GetHostByAddress (or at least for the FQDN of that item to be listed).
i.e. I’d expect the result of the below query to return true

However there are a few A Records which are not behaving in this way.
This may be a misunderstanding of DNS on my part, a misconfiguration of DNS at my company (it’s because of DNS anomalies that I’m writing this script; we found 2 servers on the same IP; so I want to check for others), or something else…


Is there a way to list all DNS names associated with a given IP address?
i.e. such that anything which returns an IP from GetHostAddresses will be listed in the results of a reverse lookup on the returned IP address?


Getting a definite list of all names associated with a given IP address is not feasible when you’re looking at the global scope, because any DNS admin can define a record for any IP address in their zone. For instance I could easily define an A record pointing to the IP address

It’s less impossible if you’re reducing the scope to just your organization. However, you still need to enumerate all forward lookup zones on your organization’s DNS servers and check the address of each A record. The answers to the ServerFault question you found do this zone enumeration. You need DNS admin privileges for it, though.

The reason why this gets so complicated is that technically there’s no relation between forward and reverse lookup zones. There’s no technical requirement for any A record to have any PTR record at all (much less a matching one). You can have two records


with no problem. Or multiple A records with no PTR record. Or PTR records with no A record.

Microsoft’s DNS server allows you to associate a PTR record with an A record, but that’s just a convenience feature. Again, there’s no technical requirement in the Domain Name System for this association.


Get all DNS records associated with an IP by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply