Retrieving All IPs Associated with a Domain : gethostbynamel « DNS « PHP






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";

        }

    }
?>
  
  








Related examples in the same category

1.Reverse Lookup of IPs Based on Domain