PHP get DNS records without caching
Question
Does anyone know how its possible to retrieve the DNS records for a domain.
I have been using php and this function: dns_get_record
to do this so far but have realized that this command gets cached DNS records and therefore not the up to date information.
Does anyone know a way around this in PHP or some other language?
Solution
The simplest solution would be to use Net_DNS PEAR Package.
OTHER TIPS
Do you really need that? DNS records doesn't change that often, and bypassing local cache will only slow queries down (especially if you start making recursive ones), with no real gain.
If you do need that, find or write a DNS resolver that can make recursive queries.
Maybe it's not a "polite fix" but from php you can also call system commands and shell scripts:
i.e:
$ host -t ns stackoverflow.com
stackoverflow.com name server cf-dns02.stackoverflow.com.
stackoverflow.com name server cf-dns01.stackoverflow.com.
So:
<?php
echo '<pre>';
$last_line = system('ls', $retval);
echo '
</pre>
last line: ' . $last_line . '
return value: ' . $retval;
?>