Jump to content

Different types of returns using gethostbyaddr() and REMOTE_ADDR


Recommended Posts

can someone explain to me why PHP returns so many different variants when throwing out visitor info using this piece of code?

$ip = gethostbyaddr($_SERVER['REMOTE_ADDR']);

here are some examples I have seen recently:


now, obviously i can understand the google one, and a few others. but, given the info and insight on these pages: https://www.php.net/manual/en/function.gethostbyaddr.php , and https://www.php.net/reserved.variables.server , why are the returns so different for different people? why does PHP see all different kinds of things? is the cause the way the user’s server is configured? some identifying info OF the server? and what about reserved IPs? like the “10.xx…” one I listed above? I’ve seen hundreds from that pool, and other blocks of reserved ones, and they have never had alpha-chars included in their captures. it’s always only the IP numbers. there a reason for that? really, all I’m looking for is why I see what I see. anyone help? furthermore, does anyone know if other server-side languages like c#, python, ruby or any js frameworks return different results than PHP ever would? thanks.

Link to comment
Share on other sites

You know how DNS can turn a name like forums.phpfreaks.com into an IP address like And how if the DNS isn't setup then you can't get to the website?

Similar thing for turning IP addresses into names. Sometimes they're configured, sometimes they're not.

Nothing you can do about it.

Link to comment
Share on other sites

More or less.  A reverse DNS entry (IP to Name) is not required so it may or may not exist for any given IP.  If it does exist, the IP owner can make it whatever they want it to be.

For the majority of IPs the reverse entry is controlled by the host or ISP.  An ISP will generally either not have a reverse entry or it will be something dynamically generated.   A hosting service will generally be similar to an ISP, but some do allow the end-user to control the reverse entry if they have a dedicated IP.  With the ubiquity of shared hosting these days though the reverse generally just is something generic rather than mapping to a domain similar to a forward lookup mapping to an ip.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.