I am using checkdnsrr
on Windows with PHP 5.3 and it always returns false.
dns_get_record
, however, works.
echo ("test.com dns check: ". checkdnsrr("test.com","NS")); //false!!
print_r(dns_get_record("test.com",DNS_NS)); //returns the right data
I guess I found something (tried on windows, PHP 5.3.0, from CLI) :
When I do this :
$tests = array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY');
foreach ($tests as $type) {
echo " Type = $type : ";
var_dump(checkdnsrr("test.com", $type));
}
I get this :
C:\bin\php-5.3\tests>c:\bin\php-5.3\php.exe test-dns.php
bool(true)
test.com dns check:
Type = A : bool(false)
Type = MX : bool(false)
Type = NS : bool(false)
Type = SOA : bool(false)
Type = PTR : bool(false)
Type = CNAME : bool(false)
Type = AAAA : bool(false)
Type = A6 : bool(false)
Type = SRV : bool(false)
Type = NAPTR : bool(false)
Type = TXT : bool(false)
Type = ANY : bool(false)
So, none of the tests gives "true" :-(
But when I try with another domain :
$tests = array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY');
foreach ($tests as $type) {
echo " Type = $type : ";
var_dump(checkdnsrr("pascal-martin.fr", $type));
}
(tested on this one because I know what's on it, and wanted to test for a specific idea ^^ )
I get :
C:\bin\php-5.3\tests>c:\bin\php-5.3\php.exe test-dns.php
bool(true)
test.com dns check:
Type = A : bool(true)
Type = MX : bool(true)
Type = NS : bool(true)
Type = SOA : bool(true)
Type = PTR : bool(true)
Type = CNAME : bool(true)
Type = AAAA : bool(true)
Type = A6 : bool(true)
Type = SRV : bool(true)
Type = NAPTR : bool(true)
Type = TXT : bool(true)
Type = ANY : bool(true)
So, the function seems to be working... For at least some domains !
Why could that be ?
Maybe there's something not configured on the DNS server of test.com ? And that something is configured on pascal-martin.fr ?
I don't know DNS systems well enough to tell :-(
Here a couple of outputs from some commands (from Linux) :
$ dig pascal-martin.fr
; <<>> DiG 9.5.1-P2 <<>> pascal-martin.fr
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22164
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;pascal-martin.fr. IN A
;; ANSWER SECTION:
pascal-martin.fr. 86400 IN A 213.186.33.2
;; Query time: 29 msec
;; SERVER: 212.27.40.241#53(212.27.40.241)
;; WHEN: Fri Aug 7 00:00:47 2009
;; MSG SIZE rcvd: 50
and :
$ dig test.com
; <<>> DiG 9.5.1-P2 <<>> test.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62572
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;test.com. IN A
;; ANSWER SECTION:
test.com. 7200 IN A 204.12.0.50
;; Query time: 136 msec
;; SERVER: 212.27.40.241#53(212.27.40.241)
;; WHEN: Fri Aug 7 00:00:51 2009
;; MSG SIZE rcvd: 42
Seems to be almost the same... so not a problem here ?
Let's try another one :
$ host pascal-martin.fr
pascal-martin.fr has address 213.186.33.2
pascal-martin.fr mail is handled by 100 mxb.ovh.net.
pascal-martin.fr mail is handled by 1 mx0.ovh.net.
And :
$ host test.com
test.com has address 204.12.0.50
Well, here, there is a difference ! Might the problem be caused by the fact that test.com resolves to an IP, but has no MX entry ? Or something like this ?
Maybe it is : when I use dns_get_record
to test for MX DNS entries, I have no result for test.com :
array(0) {
}
But I have two for pascal-martin.fr :
array(2) {
[0]=>
array(6) {
["host"]=>
string(16) "pascal-martin.fr"
["type"]=>
string(2) "MX"
["pri"]=>
int(100)
["target"]=>
string(11) "mxb.ovh.net"
["class"]=>
string(2) "IN"
["ttl"]=>
int(14481)
}
[1]=>
array(6) {
["host"]=>
string(16) "pascal-martin.fr"
["type"]=>
string(2) "MX"
["pri"]=>
int(1)
["target"]=>
string(11) "mx0.ovh.net"
["class"]=>
string(2) "IN"
["ttl"]=>
int(14481)
}
}
Well, I don't really know "why"... But at least here are a few pointers...
I can't find anything else in the php documentation ; so, I don't know if it's intended behaviour or not :-(
Anyway : good luck !
EDIT : well, there might really be some kind of problem under windows, because when I try with Linux, I get :
For test.com :
$ php temp.php
Type = A : bool(true)
Type = MX : bool(false)
Type = NS : bool(true)
Type = SOA : bool(true)
Type = PTR : bool(false)
Type = CNAME : bool(false)
Type = AAAA : bool(false)
Type = A6 : bool(false)
Type = SRV : bool(false)
Type = NAPTR : bool(false)
Type = TXT : bool(false)
Type = ANY : bool(true)
And, for pascal-martin.fr :
$ php temp.php
Type = A : bool(true)
Type = MX : bool(true)
Type = NS : bool(true)
Type = SOA : bool(true)
Type = PTR : bool(false)
Type = CNAME : bool(false)
Type = AAAA : bool(false)
Type = A6 : bool(false)
Type = SRV : bool(false)
Type = NAPTR : bool(false)
Type = TXT : bool(false)
Type = ANY : bool(true)
So, not the same thing (always true or always false) I got on windows...
Maybe there something like, on windows, the function is always looking for MX entry, not taking into account the second parameter ?
(Just a really wild guess ^^)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With