How to get all IPs associated with a domain in PHP

1 Answer

0 votes
$domainname = "microsoft.com";

$ips = gethostbynamel($domainname);

if(!$ips) {

    echo "domain name not found";

} else {

    foreach ($ips as $ip) 
        echo "IP: $ip<br />";
}  

/*
run:

IP: 104.40.211.35
IP: 191.239.213.197
IP: 23.100.122.175
IP: 104.43.195.251
IP: 23.96.52.53

*/

 



answered Oct 6, 2016 by avibootz

Related questions

2 answers 216 views
1 answer 156 views
1 answer 116 views
1 answer 128 views
1 answer 116 views
116 views asked Jul 16, 2024 by avibootz
...