Reputation: 299
Sometimes when I call gethostbyaddr() it returns the correct Host-name, however sometimes it returns the IP Address, which I know it's designed to do when the call fails to resolve the Host-name.
It is absolutely crucial that I get the Host-names as all the IP address's are Dynamic (2 day lease) so I need the Host-name so that I can have a valid Primary Key when I save the Host-name and IP pair to a database. I literally have 2 printers and 2 computers side by side and one of each PHP can resolve into a host-name and the other printer and computer returns the IP Address.
How do I get PHP to resolve the Host-name for all devices?
Also, does anyone know how it resolves the Host-name? DNS? WINS?
I can run any tests on these two printers to check their IPv4 configuration if necessary.
Upvotes: 1
Views: 454
Reputation: 3950
gethostbyaddr()
returns the host name on success, the unmodified ip_address on failure, or FALSE on malformed input.
After checking the function on around 20 static ip assigned machines and around 5 printers it returned me the ip for machines and printers which were either down or were either configured differently e.g. a router or a gateway.
So, you need to check what policies are restricting gethostbyaddr()
to return host name from your one computer and printer.
Upvotes: 1