#33170 [Bgs->Csd]: IPv6: gethostbyname() fails on resolving IPv6 hostnames
| From: | joey@php.net | Date: | Tue, 21 Apr 2009 00:54:28 +0000 |
| Subject: | #33170 [Bgs->Csd]: IPv6: gethostbyname() fails on resolving IPv6 hostnames | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2118@lists.php.net to get a copy of this message | ||
ID: 33170
Updated by: joey@php.net
Reported By: web at vollbrecht dot net
-Status: Bogus
+Status: Closed
-Bug Type: Network related
+Bug Type: Documentation problem
Operating System: Linux 2.6.10-1
PHP Version: 4.3.10
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
gethostbyname and gethostbynamel are now documented as giving the
"IPv4
address"
Previous Comments:
------------------------------------------------------------------------
[2005-05-28 20:16:28] wez@php.net
gethostbyname() is an IPv4 only function.
inet_pton and inet_ntop are possible alternatives that are available in
PHP 5.
------------------------------------------------------------------------
[2005-05-28 13:25:15] web at vollbrecht dot net
Description:
------------
perhaps related to #12678.
gethostbyname() gives the IPv6 hostname back instead if the IPv6 ip. In
IPv4 everything works fine.
Note: IPs and hostnames in the following snipplets are replaced with
example entries. It was tested with working IPs both in IPv4 and IPv6.
Reproduce code:
---------------
$client_ip = $_SERVER["REMOTE_ADDR"];
$client_hostname = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
$client_hostname2ip =
gethostbyname(gethostbyaddr($_SERVER["REMOTE_ADDR"]));
echo $client_ip."->".$client_hostname."->".$client_hostname2ip;
Expected result:
----------------
In IPv4:
10.11.12.13->server.domain.de->10.11.12.13
In IPv6:
3ffe:1::1->server.ipv6.domain.de->3ffe:1::1
Actual result:
--------------
In IPv4 (working fine): 10.11.12.13->server.domain.de->10.11.12.13
In IPv6 (last output broken):
3ffe:1::1->server.ipv6.domain.de->server.ipv6.domain.de
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33170&edit=1