Doc #33170 [Com]: IPv6: gethostbyname() fails on resolving IPv6 hostnames
| From: | epgvozdet at gmail dot com | Date: | Tue, 18 Apr 2017 13:44:21 +0000 |
| Subject: | Doc #33170 [Com]: IPv6: gethostbyname() fails on resolving IPv6 hostnames | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14645@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=33170&edit=1
ID: 33170
Comment by: epgvozdet at gmail dot com
Reported by: web at vollbrecht dot net
Summary: IPv6: gethostbyname() fails on resolving IPv6
hostnames
Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Linux 2.6.10-1
PHP Version: 4.3.10
Block user comment: N
Private report: N
New Comment:
Still not working properly:
Reproduce code:
---------------
$ip6 = "2620:0:860:ed1a::1";
$client_hostname = gethostbyaddr($ip6);
$client_hostname2ip = gethostbyname(gethostbyaddr($ip6));
echo $ip6."->".$client_hostname."->".$client_hostname2ip;
Expected result:
----------------
2620:0:860:ed1a::1->text-lb.codfw.wikimedia.org->2620:0:860:ed1a::1
Actual result:
--------------
2620:0:860:ed1a::1->text-lb.codfw.wikimedia.org->208.80.153.224
Previous Comments:
------------------------------------------------------------------------
[2013-09-04 08:32:11] daverandom@php.net
Automatic comment from SVN on behalf of daverandom
Revision: http://svn.php.net/viewvc/?view=revision&revision=331286
Log: Typo fix in MySQLi quick start
---
Provided by Anonymous #33170
------------------------------------------------------------------------
[2009-04-21 00:54:28] joey@php.net
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"
------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=33170&edit=1