#33170 [Opn->Bgs]: IPv6: gethostbyname() fails on resolving IPv6 hostnames
| From: | wez@php.net | Date: | Sat, 28 May 2005 18:16:29 +0000 |
| Subject: | #33170 [Opn->Bgs]: IPv6: gethostbyname() fails on resolving IPv6 hostnames | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79652@lists.php.net to get a copy of this message | ||
ID: 33170
Updated by: wez@php.net
Reported By: web at vollbrecht dot net
-Status: Open
+Status: Bogus
Bug Type: Network related
Operating System: Linux 2.6.10-1
PHP Version: 4.3.10
New Comment:
gethostbyname() is an IPv4 only function.
inet_pton and inet_ntop are possible alternatives that are available in
PHP 5.
Previous Comments:
------------------------------------------------------------------------
[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