Bug #73518 [Opn->Fbk]: gethostbyaddr unnecessarily attempts to resolve the domain name back to IP addr
| From: | requinix@php.net | Date: | Sun, 20 Nov 2016 20:55:40 +0000 |
| Subject: | Bug #73518 [Opn->Fbk]: gethostbyaddr unnecessarily attempts to resolve the domain name back to IP addr | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205492@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73518&edit=1
ID: 73518
Updated by: requinix@php.net
Reported by: teo8976 at gmail dot com
Summary: gethostbyaddr unnecessarily attempts to resolve the
domain name back to IP addr
-Status: Open
+Status: Feedback
Type: Bug
Package: HTTP related
Operating System: linux
PHP Version: 5.6.28
Block user comment: N
Private report: N
New Comment:
https://github.com/php/php-src/blob/PHP-5.6.28/ext/standard/dns.c#L153
As you can see PHP calls gethostbyaddr(3) and only does so once. Do you have any evidence to support
the claim that there are two lookups? Is there something on your system, or in an upstream DNS
server, that is responsible instead of PHP?
Previous Comments:
------------------------------------------------------------------------
[2016-11-20 20:32:05] php at duncanc dot co dot uk
I don't think this is a PHP issue. As far as I'm aware this functionality comes from a C
library (libc)
------------------------------------------------------------------------
[2016-11-14 20:32:11] teo8976 at gmail dot com
Description:
------------
When you call gethostbyaddr($someip), it does 2 DNS lookups:
1 - looks up the IP to find the corresponding domain name, i.e. does its job
2 - then looks up the domain name, as if it needed to find the corresponding IP address
The second is completely unnecessary, especially considering that, if it times out, it nonetheless
returns the host name found at step 1 (if, in this case, it returned false or the IP address, one
may perhaps argue that it makes sense in order to verify that the host name is correct or
something).
Test script:
---------------
<?php
echo gethostbyaddr('95.232.181.106');
Expected result:
----------------
should immediately print:
host106-181-dynamic.232-95-r.retail.telecomitalia.it
At http://mxtoolbox.com/SuperTool.aspx?action=ptr%3a95.232.181.106&run=toolpage#
you can verify that it takes a fraction of a second to do the reverse lookup
Actual result:
--------------
From most servers, it takes more than 15 seconds (I guess it depends on how long it takes for the
DNS resolver to time out), and then it prints the expected domain name.
Apparently, there is something wrong with this domain which prevents the name from being resolved to
an IP:
http://mxtoolbox.com/SuperTool.aspx?action=a%3ahost106-181-dynamic.232-95-r.retail.telecomitalia.it&run=toolpage
However, as explained above, the name->IP lookup is completely unnecessary.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73518&edit=1