http://www.perlmonks.org?node_id=1002931


in reply to Re: Reliable FQDN from IP
in thread Reliable FQDN from IP

I'd already looked into using the following which I think I'm right in saying is fundamentally the same as your code snippet suggestion (unless of course yours forces BIND in which case perfect!):
$hostname = gethostbyaddr( inet_aton($ip), AF_INET );
But unfortunately gethostbyaddr by design searches the sources listed in /etc/nsswitch.conf or similar.

For me this is undesirable as my single source of truth for the FQDN is not the client but DNS. With /etc/nsswitch.conf set to local followed by bind the query is likely to resolve from /etc/hosts first which cannot be relied upon to be accurate.