node.js dns.resolveAny返回一个空数组

时间:2017-11-26 02:31:20

标签: node.js dns

我使用dns.resolveAny功能检查某些域的DNS信息。

我发现有一点奇怪的是,对于某些域,dns.resolveAny返回一个空数组而nslookup命令没有。

以下是一个例子:

// node.js version >= 9.2 is required

const dns = require('dns')

dns.resolveAny('www.ifshop.com.tw', (err, ret) => {
  if (err) {
      console.log(`err: ${err}`)
  } else {
      console.log(`ret: ${JSON.stringify(ret)}`)  // JSON.stringify(ret) == [] here
  }
})

resolveAny返回[]。但是nslookup成功返回了www.ifshop.com.tw的CNAME记录。

> nslookup www.ifshop.com.tw
Server:     192.168.1.1
Address:    192.168.1.1#53

Non-authoritative answer:
www.ifshop.com.tw   canonical name = s1759.dname.91app.io.
s1759.dname.91app.io    canonical name = proxy.letssl.91app.io.
proxy.letssl.91app.io   canonical name = proxy-letssl-91app-io-196811564.ap-northeast-1.elb.amazonaws.com.
Name:   proxy-letssl-91app-io-196811564.ap-northeast-1.elb.amazonaws.com
Address: 54.178.248.57
Name:   proxy-letssl-91app-io-196811564.ap-northeast-1.elb.amazonaws.com
Address: 52.196.80.17

为什么会这样?

这是resolveAny的错误吗?

或者www.ifshop.com.tw的DNS配置是否存在问题?

我还发现dns.resolveCname成功返回CNAME。

// node.js version >= 9.2 is required

const dns = require('dns')

dns.resolveCname('www.ifshop.com.tw', (err, ret) => {
  if (err) {
      console.log(`err: ${err}`)
  } else {
      console.log(`ret: ${JSON.stringify(ret)}`)
  }
})

此处JSON.stringify(ret)等于["s1759.dname.91app.io"]

1 个答案:

答案 0 :(得分:1)

我将nslookup的类型设置为any。然后我找到了以下信息。

nslookup
> set type=any
> www.ifshop.com.tw
Server:     10.11.1.5
Address:    10.11.1.5#53

Non-authoritative answer:
www.ifshop.com.tw   hinfo = "ANY obsoleted" "See draft-ietf-dnsop-refuse-any"

Authoritative answers can be found from:

根据上述信息,我们可以推断DNS提供商拒绝回复any类型的查询。