I use CloudFlare, so my server's IP address is hidden, and I want to keep it that way. When I make an HTTP request obviously my IP will be revealed. But does gethostbyaddr
reveals my IP address? I want to get the user's IP host, so I do:
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
Will the user be able to find out my server's IP address by this?
gethostbyaddr
does a reverse DNS lookup. It does not contact the host directly. However, it may contact DNS servers to do the reverse lookup.
Typically PHP will ask the system's DNS service for the reverse lookup, and if the answer doesn't happen to be cached, the service will contact its closest DNS server to get the answer. If that doesn't have the answer, it will go out and contact its closest upstream server etc. etc. until the answer comes back.
So, rarely if ever should the server reach out further than its closest DNS server. It's certainly not impossible though, and if your server happens to contact a DNS server which your user happens to have control over, that user could see the incoming DNS resolution request.
That will be extremely rare, and again, typically the only DNS server your server will have contact with is its closest DNS server, but cannot be entirely ruled out.