PHP get DNS records without caching

Does anyone know how one can get DNS records for a domain.

I have used php and this function: dns_get_record

to do it so far, but realized that this command is getting cached DNS records and therefore not the latest information.

Does anyone know about this in PHP or another language?

+2


source to share


3 answers


The simplest solution would be to use the Net_DNS PEAR package.



+2


source


Do you really need it? DNS records don't change that often and bypassing the local cache will only slow down queries (especially if you start doing recursive ones), with no real gain.



If you need it, find or write down a DNS resolver that can do recursive queries.

+2


source


This may not be a "polite fix", but with php you can also invoke system commands and shell scripts:

ie:

$ 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;
?>

      

0


source