php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43687 gethostbyname() can't return a valid ip address.
Submitted: 2007-12-27 09:29 UTC Modified: 2008-02-05 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: php at xuefeng dot org Assigned:
Status: No Feedback Package: Network related
PHP Version: 5.2.5 OS: Redhat 2.6.9-42.ELsmp #1 SMP i68
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at xuefeng dot org
New email:
PHP Version: OS:

 

 [2007-12-27 09:29 UTC] php at xuefeng dot org
Description:
------------
When trying to resolv the ip address of a hostname given in /etc/hosts, it's works fine, but does not work when trying to resolv via the DNS server though.

btw: those test code works fine with php 5.2.1

Reproduce code:
---------------
var_dump(dns_get_record("xxx.xxx.com"));
var_dump(fsockopen("xxx.xxx.com", 80, $error, $errstr));


Expected result:
----------------
array(1) {
  [0]=>
  array(5) {
    ["host"]=>
    string(12) "xxx.xxx.com"
    ["type"]=>
    string(1) "A"
    ["ip"]=>
    string(13) "192.168.200.6"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(86400)
  }
}
resource(20) of type (stream)

Actual result:
--------------
array(1) {
  [0]=>
  array(5) {
    ["host"]=>
    string(12) "xxx.xxx.com"
    ["type"]=>
    string(1) "A"
    ["ip"]=>
    string(13) "192.168.200.6"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(86400)
  }
}
<br />
<b>Warning</b>:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in <b>/opt/wwwroot/qun_inner/modules/club/my_signatures.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to xxx.xxx.com:80 (Unknown error) in <b>/opt/wwwroot/qun_inner/modules/club/my_signatures.php</b> on line <b>68</b><br />
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-30 16:24 UTC] iliaa@php.net
Is the xxx.xxx.com domain defined via DNS entry or via a local hosts 
file?
 [2007-12-30 18:31 UTC] php at xuefeng dot org
defined via DNS entry .
 [2008-01-28 23:54 UTC] tony2001@php.net
Apparently, the second DNS request fails.
You can check it out with strace/tcpdump.
 [2008-02-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-04-08 05:38 UTC] bole dot chen at gmail dot com
I have this problem on RHEL5 too.
My sloved is "chmod 644 /etc/hosts"
Simple,but useful for me.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 07:01:29 2024 UTC