Is there any way to get a given website all IP addresses?
Can CURL do it ? Is it possible in PHP ?
Is there any way to get a given website all IP addresses?
Can CURL do it ? Is it possible in PHP ?
Use dns_get_record
, like this:
$all_records = dns_get_record('example.com');
$ips = array();
foreach ($all_records as $r) {
if ($r['type'] == 'A') {
$ips[] = $r['ip'];
}
if ($r['type'] == 'AAAA') {
$ips[] = $r['ipv6'];
}
}
var_export($ips);
gethostbynamel
also provides a simplified interface if you're only interested in IPv4 addresses.
Note that due to the limited response size and geographical preferences, you may need to ask this query multiple times from multiple locations to get all (or most) addresses of a well-frequented domain such as google.com.