Question

I am working on a PHP program that needs to determine related url's sharing an IP address. For example, I have the hostname, say, www.example.com and I want to determine what other urls share that IP. I'm not sure whether or not to use DNS_GET_RECORD(). Gethostname() seems to only return one IP address. If I use DNS_GET_RECORD() won't that just return the records for that hostname? As you can tell, I'm somewhat confused.

Was it helpful?

Solution

You can't. There's no general way to look up all hostnames that resolve to a given IP. (For example, if I decided to create a record on my DNS server right now that pointed foo.example.com to 1.2.3.4, there's no way that you could find that out unless you happened to look it up. No lookup on 1.2.3.4 would ever reveal it to you.)

There are a few tools available online that can give you a partial listing, but they're all based on picking up hostnames from domain name registries, web crawls, and the like and keeping track of what they all resolve to. No magic to it, just a lot of hard work to build a database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top