Running PHP 5.2 on Linux, I am running a series of queries with dns_get_record()
. It would appear from the documentation that this function replicates dig(1) but I am seeing inconsistencies. My goal is to get the primary and secondary nameservers that are authoritative for the domains that each hostname belongs to.
dns_get_record('example.com', DNS_NS)
returns good results.
dns_get_record('www.example.com', DNS_NS)
returns nothing.
dns_get_record('www.example.com', DNS_ANY)
returns only an A-record.
dns_get_record('www.example.com', DNS_SOA)
returns nothing.
However, from a command line using dig, I can always get at least the SOA:
dig www.example.com NS
or
dig www.example.com SOA
return a valid AUTHORITY SECTION (IN SOA) containing the nameservers.
How can I replicate this in PHP? I have tried the PEAR Net_DNS module and seen similar shenanigans as with dns_get_record()
.