2009-08-06 18 views
5

Sto usando checkdnsrr su Windows con PHP 5.3 e restituisce sempre false.checkdnsrr restituisce sempre false su windows

dns_get_record, tuttavia, funziona.

echo ("test.com dns check: ". checkdnsrr("test.com","NS")); //false!! 
print_r(dns_get_record("test.com",DNS_NS)); //returns the right data 
+0

Funziona con qualsiasi altro tipo di record DNS? –

+0

i vantaggi che ottengo nel senso che le persone hanno lo stesso problema? – user121196

+0

no, infatti ne ho provato uno: \t echo ("test dns test.com:". Checkdnsrr ("test.com", "ANY")); restituisce false – user121196

risposta

3

immagino ho trovato qualcosa (provato su Windows, PHP 5.3.0, da CLI):

Quando faccio questo:

$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)); 
} 

ottengo questo:

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) 

Quindi, nessuno dei test dà "vero" :-(


Ma wh it provo con un altro dominio:

$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)); 
} 

(testato su questo perché io so cosa c'è su di esso, e voluto mettere alla prova per una specifica idea ^^)

ottengo:

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) 

Quindi, la funzione sembra funzionare ... Per almeno alcuni domini!


Perché potrebbe essere?

Forse c'è qualcosa non configurato sul server DNS di test.com? E che qualcosa è configurato su pascal-martin.fr?

Non so sistemi DNS abbastanza bene per raccontare :-(


qui un paio di uscite da alcuni comandi (da 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 

e:

$ 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 

Sembra quasi lo stesso ... quindi non è un problema qui?

Proviamo un altro:

$ 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. 

E:

$ host test.com 
test.com has address 204.12.0.50 

Bene, qui, c'è una differenza! Il problema potrebbe essere causato dal fatto che test.com risolve un IP, ma non ha una voce MX? O qualcosa del genere?


Forse è: quando uso dns_get_record per testare MX voci DNS, non ho alcun risultato test.com:

array(0) { 
} 

ma ho due per 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) 
    } 
} 


Beh, io non so davvero "perché" ... Ma almeno qui ci sono alcune indicazioni ...

Non riesco a trovare nient'altro nella documentazione php; così, non so se è destinato comportamento o no :-(

In ogni caso: in bocca al lupo



EDIT: bene, ci potrebbe davvero essere una sorta di problema sotto finestre, perché quando provo con Linux, ottengo:

Per 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) 

E, per 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) 

Quindi, non è la stessa cosa (sempre vero o sempre false) sono salito su finestre ...

Forse c'è qualcosa di simile, sulle finestre , la funzione cerca sempre l'ingresso MX, non tenendo conto del secondo parametro?
(Solo un'ipotesi molto selvaggia ^^)

+0

che potrebbe essere la ragione (sarebbe sciocco se lo fosse). Immagino che dovrò scavare nel codice di dns_get_record su Windows per scoprirlo ... ottima risposta però! Grazie! – user121196

+0

Prego! Buona fortuna con la cosa che scava! –

0

Questa funzionalità non è disponibile per le versioni di PHP su Windows prima 5.3.0

Vedere il changelog a php.net's manual page for checkdnsrr per informazioni. Controlla anche i commenti per le sostituzioni.

+1

Ma sta usando PHP 5.3 –

+1

Hmm ... quindi è ... un bug? – Mez

Problemi correlati