Jump to content

reverse lookup with IP


denoteone

Recommended Posts

I am using gethostbyaddr  to resolve a site visitors IP.  Would this be the same as a reverse look up on an IP?

Would this be the same as using Network Solutions Whois search?  I am getting some weird entries in my database. lol  Any body have any insight on this?

Link to comment
https://forums.phpfreaks.com/topic/143687-reverse-lookup-with-ip/
Share on other sites

ok let me ask this a different way. why if I look up an IP address with gethostbyaddr();

 

sometimes it just returns the ip again. but if I look the same IP up on www.who.is  I get more info.

 

where does the gethostbyaddr(); function get its info. is there another php function that would work better for this?

 

The IP address is returned on failure of the function call. I found these on php.net...might work for you:

 

<?php
// For Linux...

function gethost ($ip) {
$host = `host $ip`;
return (($host ? end ( explode (' ', $host)) : $ip));
}

// For Win32...

function nslookup ($ip) {
$host = split('Name:',`nslookup $ip`);
return ( trim (isset($host[1]) ? str_replace ("\n".'Address:  '.$ip, '', $host[1]) : $ip));
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.