Net_DNS: Examples: PTR Lookup
How to perform an Inverse Query (PTR query):
require_once("Net/DNS.php");
$res = new Net_DNS_Resolver();
$res->debug = 1;
$answer = $res->search("208.77.188.166");
echo "<BR><HR><BR>";
print_r($answer);
This example will query the name server and output the following:
;; search(166.188.77.208.in-addr.arpa., PTR, IN) ;; query(166.188.77.208.in-addr.arpa., PTR, IN) ;; using extended PHP sockets ;; send_udp(208.79.80.18:53): sending 45 bytes ;; timeout set to 5 seconds ;; answer from 208.79.80.18:53: 74 bytes ;; HEADER SECTION ;; id = 2208 ;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 1 ;; ra = 1 rcode = NOERROR ;; qdcount = 1 ancount = 1 nscount = 0 arcount = 0 ;; QUESTION SECTION (1 record) ;; ;166.188.77.208.in-addr.arpa. IN PTR ;; ANSWER SECTION (1 record) 166.188.77.208.in-addr.arpa. 21600 IN PTR www.example.com. ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (0 records)
Net_DNS_Packet Object ( [debug] => 1 [header] => Net_DNS_Header Object ( [id] => 2208 [qr] => 1 [opcode] => QUERY [aa] => 0 [tc] => 0 [rd] => 1 [ra] => 1 [rcode] => NOERROR [qdcount] => 1 [ancount] => 1 [nscount] => 0 [arcount] => 0 ) [compnames] => Array ( ) [answerfrom] => 208.79.80.18 [answersize] => 74 [question] => Array ( [0] => Net_DNS_Question Object ( [qname] => 166.188.77.208.in-addr.arpa [qtype] => PTR [qclass] => IN ) ) [answer] => Array ( [0] => Net_DNS_RR_PTR Object ( [name] => 166.188.77.208.in-addr.arpa [type] => PTR [class] => IN [ttl] => 21600 [rdlength] => 17 [rdata] => wwwexamplecom [ptrdname] => www.example.com ) ) [authority] => Array ( ) [additional] => Array ( ) )