tags:

views:

128

answers:

1
+1  Q: 

php dns records

Hi there

When I use dns_get_record within a php script to get a list of DNS records for a domain, a list of records are returned.

But then if I run the script again it does not return all of the same results(ie it just returns the name servers) then if I run it again it works etc.

This is the code I am using:

$result = dns_get_record("php.net");
print_r($result);

Is there a better function to use or a more reliable way of querying for DNS records?

NOT WORKING:

Array ( [0] => Array ( [host] => php.net [type] => NS [target] => remote2.easydns.com [class] => IN [ttl] => 38772 ) [1] => Array ( [host] => php.net [type] => NS [target] => ns1.easydns.com [class] => IN [ttl] => 38772 ) [2] => Array ( [host] => php.net [type] => NS [target] => ns2.easydns.com [class] => IN [ttl] => 38772 ) [3] => Array ( [host] => php.net [type] => NS [target] => remote1.easydns.com [class] => IN [ttl] => 38772 ) )

WORKING:

Array ( [0] => Array ( [host] => php.net [type] => MX [pri] => 5 [target] => osu1.php.net [class] => IN [ttl] => 72984 ) [1] => Array ( [host] => php.net [type] => MX [pri] => 15 [target] => smtp.osuosl.org [class] => IN [ttl] => 72984 ) [2] => Array ( [host] => php.net [type] => NS [target] => remote2.easydns.com [class] => IN [ttl] => 30054 ) [3] => Array ( [host] => php.net [type] => NS [target] => ns1.easydns.com [class] => IN [ttl] => 30054 ) [4] => Array ( [host] => php.net [type] => NS [target] => ns2.easydns.com [class] => IN [ttl] => 30054 ) [5] => Array ( [host] => php.net [type] => NS [target] => remote1.easydns.com [class] => IN [ttl] => 30054 ) )

+1  A: 

Adding DNS_ALL to the function call should work

$result = dns_get_record("php.net",DNS_ALL);
print_r($result);

To ensure you are collecting all the different records.

Jamie Lewis