php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40351 [BOGUS] DNS resolution fails with PHP
Submitted: 2007-02-04 13:34 UTC Modified: 2007-02-05 12:34 UTC
From: dae at datasec dot no Assigned:
Status: Not a bug Package: *Network Functions
PHP Version: 4.4.4 OS: Trustix 3.0.5 RC1
Private report: No CVE-ID: None
 [2007-02-04 13:34 UTC] dae at datasec dot no
Description:
------------
PHP can not do DNS-resolution,
all other software or parts of the OS can.

Reproduce code:
---------------
$foo = gethostbyaddr('69.147.83.197');
echo 'gethostbyaddr [should show a hostname] : '.$foo."\n";

$foo = gethostbyname("php.net");
echo 'gethostbyname [should show an ip] : '.$foo."\n";

$host = explode('@', 'webmaster@php.net');
if(!checkdnsrr($host[1].'.', 'MX') ) {
	echo "No MX record found for webmaster@php.net\n";
}

Expected result:
----------------
gethostbyaddr [should show a hostname] : y2.php.net
gethostbyname [should show an ip] : 69.147.83.197

Actual result:
--------------
gethostbyaddr [should show a hostname] : 69.147.83.197
gethostbyname [should show an ip] : php.net
No MX record found for webmaster@php.net

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-05 09:26 UTC] tony2001@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2007-02-05 10:05 UTC] dae at datasec dot no
Sorry for not providing enough details the first time,
I wanted to be brief, but I was too brief then.
I have re-read the instructions, and if I
still don't provide enough details, 
please specify what more details you need from me.
Thank you.

PHP can not do DNS-resolution,
all other software or parts of the OS can.
Postfix log-sample:
Feb  4 13:18:42 localhost postfix/smtp[8064]: 0EED46BC0D9: to=<xxx@example.com>, relay=mx01.example.com[0.0.0.0], delay=0, status=sent (250 2.0.0 l14CIjgK005386 Message accepted for delivery)

Bash example:
~# telnet php.net 80
Trying 69.147.83.197...
Connected to php.net.

~# nslookup php.net
Server:         213.x.x.x
Address:        213.x.x.x#53

Non-authoritative answer:
Name:   php.net
Address: 69.147.83.197

~# nslookup 69.147.83.197
Server:         213.x.x.x
Address:        213.x.x.x#53

Non-authoritative answer:
197.83.147.69.in-addr.arpa      name = y2.php.net.


Error log example:
[date] [error] PHP Warning:  socket_connect() Host lookup failed [-10002]: Host name lookup failure

PHP compile option:
 './configure' '--enable-memory-limit' '--enable-safe-mode' '--enable-magic-quotes' '--enable-sockets' '--prefix=/usr/local/php_4.4.4' '--with-openssl' '--enable-force-cgi-redirect' '--with-apache=/root/inst/apache_1.3.37' '--with-zlib'
 [2007-02-05 10:19 UTC] tony2001@php.net
Does PHP CLI work for you?
 [2007-02-05 12:32 UTC] dae at datasec dot no
Problem solved. This was a bogus bug report,
and I am definately very sorry.

Thank you very much for pointing me to PHP CLI Tony,
it helped me see the problem. I am very grateful for
quick and helpful feedback. 

Only root can run PHP-CLI on my server, so
I finally figured out why php with apache couldn't
do DNS-lookups.

If anybody else experience this problem;
make sure /etc/resolv.conf are chmod 444 (or 644).
And also apache-daemon must be stopped and started
after making changes to resolv.conf.

I feel so stupid, very sorry again.

Keep up your great work with developing PHP,
it is my favorite!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC