PHP DNS 记录

发布于 2024-08-03 13:13:10 字数 1503 浏览 2 评论 0原文

当我在 php 脚本中使用 dns_get_record 来获取域的 DNS 记录列表时,会返回记录列表。

但是,如果我再次运行脚本,它不会返回所有相同的结果(即它只返回名称服务器),然后如果我再次运行它,它会工作等等。

这是我正在使用的代码:

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

是否有更好的函数使用或更可靠的方式查询 DNS 记录?

不工作:

数组 ( [0] => 数组 ( [host] => php.net [type] => NS [target] => remote2.easydns.com [class] => IN [ttl] => 38772 ) [1] => 数组 ( [主机] => php.net [类型] => NS [目标] => ns1.easydns.com [类] => IN [ttl] => 38772 ) [2] => 数组 ( [主机] => php.net [类型] => NS [目标] => ns2.easydns.com [类] => IN [ttl] => 38772 ) [3] => 数组 ( [主机] => php.net [类型] => NS [目标] => remote1.easydns.com [类] => IN [ttl] => 38772 ) )

工作:

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

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 ) )

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

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

发布评论

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

评论(1

毁我热情 2024-08-10 13:13:10

将 DNS_ALL 添加到函数调用应该可以

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

确保您正在收集所有不同的记录。

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.

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