PHP DNS 记录
当我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 DNS_ALL 添加到函数调用应该可以
确保您正在收集所有不同的记录。
Adding DNS_ALL to the function call should work
To ensure you are collecting all the different records.