PHP/DNS/gethostbynamel
Retrieving All IPs Associated with a Domain
<?php
$hostname = "google.ru";
$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";
}
}
?>
Reverse Lookup of IPs Based on Domain
<?php
$ip_addr = gethostbyname("www.google.ru");
if($ip_addr ==="www.google.ru") {
echo "Could not resolve the IP address for the host!<BR/>\n";
} else {
echo "The IP address for the host is: $ip_addr<BR/>\n";
}
?>