php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53025 checkdnsrr() result vary for specific server
Submitted: 2010-10-08 16:20 UTC Modified: 2010-10-10 19:39 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: uni at daniel-marschall dot de Assigned:
Status: Not a bug Package: *Network Functions
PHP Version: Irrelevant OS: Various
Private report: No CVE-ID: None
 [2010-10-08 16:20 UTC] uni at daniel-marschall dot de
Description:
------------
I am trying to find out if a webserver has A-records or not. I found out that for the server "us.ibm.com" the results vary from client to client. Since I am writing an OpenSource application, I wish that the results of checkdnsrr() are consistent. I am not sure if it is a bug in PHP.

Test script:
---------------
<?php

$phpver = phpversion();
echo "PHP version: $phpver<br>\r\n";
echo $_SERVER["SERVER_SIGNATURE"] . "<br>\r\n";

$server = 'us.ibm.com';

if (checkdnsrr($server, 'A')) {
        echo "$server A-record: VALID";
} else {
        echo "$server A-record: NOT VALID";
}

?>


Expected result:
----------------
I do not know which result is correct. I checked the A-record at many different webservices and each webservice has different results.

Example:

* MX Toolbox: http://mxtoolbox.com/SuperTool.aspx?action=a%3aus.ibm.com (NO A-RECORD)

* My-Addr.com: http://my-addr.com/domain-hostname-dns-records/isp-country-geo-ip-location/online-nslookup-tool/domain_info.php?domain=us.ibm.com&x=0&y=0 (A-RECORDS e32.co.us.ibm.com FOUND, but therefore no IP, so data MAY be incorrect)

* OpenDNS also outputs some A-records for that domain, but I am not sure if they are valid

* ntchosting.com: http://www.ntchosting.com/dns/host.html#Check_the_A_record - Various A-record FOUND! (e.g. e1.ny.us.ibm.com )


Actual result:
--------------
Some PHP clients output "A record found", others output "No A record found". I do not know if it is controlled by the OS, the network or the PHP version.

Examples for data I collected:

1. Tested at my Debian server (viathinksoft.de) and A-record FOUND. Software: Apache/2.2.9 (Debian) DAV/2 SVN/1.5.1 PHP/5.2.6-1+lenny8 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g mod_perl/2.0.4 Perl/v5.10.0

2. Tested at my XAMPP localhost with Windows XP Home and A-record FOUND. Software: Windows XP Home; XAMPP; Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

3. Tested at my university's server (jonathan.sv.hs-mannheim.de) and A-record NOT found. Software: Apache/2.2.8 (Fedora). PHP version: 5.2.6.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-08 17:20 UTC] dominic at sayers dot cc
Daniel - check http://bugs.php.net/bug.php?id=51844

I see you're using a mixture of PHP 5.2 and 5.3 - is this a new bug in 5.3 
perhaps?
 [2010-10-09 00:46 UTC] uni at daniel-marschall dot de
I have tried it now with PHP 5.3.3 at my Windows XP machine. Same result. A-record 
found. I expect that no A-record for this hostname is found.

Alas, I cannot change the PHP versions for the 2 webservers.
 [2010-10-09 01:50 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-10-09 01:50 UTC] pajoye@php.net
Which operating system are you using exactly? Windows (which version?) Or linux?

Windows has a different DNS implementation than unix.

Also different results may be due to the use of different DNS servers. Be sure to check that every client uses the same.

On windows you don't have to install PHP to test a new version but simply uncompress the zip somewhere and run:

php -n dns.php

from the php directory.
 [2010-10-10 06:50 UTC] uni at daniel-marschall dot de
-Status: Feedback +Status: Open
 [2010-10-10 06:50 UTC] uni at daniel-marschall dot de
Hello.

I DO think that it is a bug in PHP.

To your question, which OS I am using, please look in my initial comment again. 
I ran this testscript with wrong results on Windows AND Linux.

It is not possible that my DNS/ISP is fault since I got also a Java application 
which checks A-records and there "us.ibm.com" has no A-records. But the PHP 
script says, A-records are available.
 [2010-10-10 14:45 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-10-10 14:45 UTC] pajoye@php.net
I asked which OS and which versions of these OSes do you use. Please answer.
 [2010-10-10 16:10 UTC] uni at daniel-marschall dot de
-Status: Feedback +Status: Open
 [2010-10-10 16:10 UTC] uni at daniel-marschall dot de
WRONG results at:

- Windows XP Home 5.1.2600 SP 3, PHP 5.3.1 and PHP 5.3.3 (both PHP versions 
tested)

- Linux version 2.6.24-etchnhalf.1-686 (Debian 2.6.24-6~etchnhalf.9etch3) 
(dannf@debian.org) (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #1 
SMP Thu Feb 25 05:42:02 UTC 2010 .
 [2010-10-10 18:42 UTC] pajoye@php.net
-Status: Open +Status: Bogus -Package: Unknown/Other Function +Package: *Network Functions
 [2010-10-10 18:42 UTC] pajoye@php.net
I don't think it is a bug in PHP. Both on windows and linux PHP uses the system functions. They return the requested records and PHP only transforms them to be usable by a PHP script.

I checked the us.ibm.com domains, the issue I can see is some recursive resolution, which creates confusions with some dns clients or relays (DNS intermediate server). But that's not something PHP can solve.

Below is the answer for mines, as you can see, no A entry, checkdnsrr returns false as well, obviously.

Closing this bug as not a php bug > bogus.

Array
(
    [0] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e39.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [1] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e9.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [2] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e5.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [3] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e3.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [4] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e4.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [5] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e37.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [6] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e6.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [7] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e2.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [8] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e31.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [9] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e35.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [10] => Array
        (
            [host] => us.ibm.com
            [type] => TXT
            [txt] => v=spf1 ip4:32.97.182.0/24 ip4:32.97.110.0/24 a:d25xlcore010.ca.ibm.com a:isource.boulder.ibm.com ~all
            [entries] => Array
                (
                    [0] => v=spf1 ip4:32.97.182.0/24 ip4:32.97.110.0/24 a:d25xlcore010.ca.ibm.com a:isource.boulder.ibm.com ~all
                )

            [class] => IN
            [ttl] => 583
        )

    [11] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e38.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [12] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e8.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [13] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e32.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [14] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e33.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [15] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e1.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [16] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e34.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [17] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e36.co.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

    [18] => Array
        (
            [host] => us.ibm.com
            [type] => MX
            [pri] => 10
            [target] => e7.ny.us.ibm.com
            [class] => IN
            [ttl] => 3583
        )

)
 [2010-10-10 19:39 UTC] uni at daniel-marschall dot de
It sounds logical that PHP calls the OS's DNS resolution and it is likely that 
it is not a PHP bug. But I am just very confused about this.

I checked following script

<?php
$result = dns_get_record("us.ibm.com");
print_r($result);
?>

at the systems which output "A-records available". At these two systems, Windows 
and Debian Linux, I get the same list as you get: TXT entries and many MX 
entries.

So, my big question is: Why is checkdnsrr('us.ibm.com', 'A')=true at some 
systems when dns_get_record() is without any [type]='A' entry?
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 20:01:28 2019 UTC