PHP获取DNS记录而不缓存

发布于 2024-08-04 08:27:28 字数 157 浏览 2 评论 0原文

有谁知道如何检索域的 DNS 记录。

到目前为止,我一直在使用 php 和这个函数:dns_get_record 来执行此操作,但我意识到该命令获取缓存的 DNS 记录,因此不是最新信息。

有谁知道用 PHP 或其他语言解决这个问题的方法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟花易冷人易散 2024-08-11 08:27:29

也许这不是一个“礼貌的修复”,但从 php 你也可以调用系统命令和 shell 脚本:

即:

$ host -t ns stackoverflow.com
stackoverflow.com name server cf-dns02.stackoverflow.com.
stackoverflow.com name server cf-dns01.stackoverflow.com.

所以:

<?php
   echo '<pre>';

   $last_line = system('ls', $retval);

   echo '
    </pre>
    last line: ' . $last_line . '
    return value: ' . $retval;
?>

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;
?>
自由范儿 2024-08-11 08:27:28

最简单的解决方案是使用 Net_DNS PEAR 包。

The simplest solution would be to use Net_DNS PEAR Package.

暖树树初阳… 2024-08-11 08:27:28

你真的需要那个吗? DNS 记录不会经常更改,绕过本地缓存只会减慢查询速度(特别是当您开始进行递归查询时),而没有任何实际收益。

如果您确实需要,请查找或编写一个可以进行递归查询的 DNS 解析器。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文