|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27163 gethostbyname() returns server IP for non-existent hosts
Submitted: 2004-02-05 15:13 UTC Modified: 2004-02-05 21:26 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: turtle at rawx dot net Assigned:
Status: Not a bug Package: Network related
PHP Version: 4.3.5RC2 OS: Linux 2.4.24
Private report: No CVE-ID: None
 [2004-02-05 15:13 UTC] turtle at rawx dot net
gethostbyname() is returning my own IP address for non-existent domain names. The expected behavior is that it will return the original name back to you.

Resolving a real domain returns it's correct IP address.

This issue affects other DNS resoluton commands too... for example, checkdnsrr('','A') returns TRUE.

Using local resolution commands, the expected result (NXDOMAIN) is returned:

/:~# host
Host not found: 3(NXDOMAIN)

This may similar (same?) as bug ID <a href=''>21487</a>.

PHP configuration: ./configure --with-apxs2=/www/bin/apxs --with-config-file-path=/etc --with-mcrypt --enable-ftp --with-gd=/usr/local --with-zlib-dir=/usr/local --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-mysql --with-xml --enable-track-vars 

Reproduce code:
echo gethostbyname('');

Expected result:

Actual result:

(my server's own IP)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-05 21:26 UTC]
It works fine here, when it fails to resolve the original 
domain string is returned. If you get anything else it 
could be due to named issues on your system. 
 [2012-06-27 17:42 UTC] s at finalclass dot net
Try removing this line:
from /etc/resolve.conf file.
In my case this solved the problem.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Aug 16 20:05:44 2022 UTC