1

我想获得域的权威名称服务器。dns_get_record()看起来很简单,应该能够将权威名称服务器填充到$authns.

如果我从手册中运行示例:

<?php
$result = dns_get_record("php.net", DNS_ANY, $authns, $addtl);
echo "Result = ";
var_dump($result);
echo "Auth NS = ";
var_dump($authns);
echo "Additional = ";
var_dump($addtl);

我得到以下输出:

---snipped---
Auth NS =

null

Additional =

null

为什么 authns 和附加记录为空?

我在 Ubuntu 13.04 64 位上运行 PHP 5.5.3。

4

2 回答 2

1

如果您想要NS记录,您应该明确要求它们。

当您向本地递归服务器发送ANY请求时,您只会获得当时在递归服务器缓存中的记录,尽管如果没有此类记录,您的查询将触发ANY对该域的权威服务器的上游请求。

此外,在ANY查询中,所有返回的记录都将在“answer”部分中找到,而不是在“authority”部分中。

于 2013-09-17T13:30:35.527 回答
1

例子 :

$NS=array('8.8.8.8');
$dns_NS_array=dns_get_record("google.com", DNS_NS, $NS);
print_r($dns_NS_array);

输出 :

Array
(
    [0] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 343459
            [type] => NS
            [target] => ns1.google.com
        )

    [1] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 343459
            [type] => NS
            [target] => ns3.google.com
        )

    [2] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 343459
            [type] => NS
            [target] => ns2.google.com
        )

    [3] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 343459
            [type] => NS
            [target] => ns4.google.com
        )

)
于 2016-01-05T08:56:51.133 回答