Mega Code Archive

 
Categories / Php / DNS
 

Retrieving All IPs Associated with a Domain

<?php     $hostname = "google.com";     $ip_addrs = gethostbynamel($hostname);     if(!$ip_addrs) {         echo "Could not resolve the domain name $hostname<BR/>\n";     } else {         echo "Here is a list of IPs associated with $hostname:<BR/><BR/>\n\n";         foreach($ip_addrs as $ip) {             echo "IP: $ip<BR/>\n";         }     } ?>