title: Is there an equivalent function of nslookup command in node.js?
body: <p>Is there an equivalent function of <code>nslookup</code> in node.js?</p>
  
  <p>Here's the execution result of <code>nslookup</code> command on my MacBook Pro:</p>
  
  <pre><code>&gt; nslookup www.amagicshop.com.tw 8.8.8.8
  Server:         8.8.8.8
  Address:        8.8.8.8#53
  
  Non-authoritative answer:
  www.amagicshop.com.tw   canonical name = s16959.dname.91app.io.
  s16959.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
  </code></pre>
  
  <p>I'm wondering if there is a function in node.js which, given <code>www.amagicshop.com.tw</code>, and <code>8.8.8.8</code> as input, also returns<br>
  <code>s16959.dname.91app.io.</code>, 
  <code>proxy.letssl.91app.io.</code>, <code>proxy-letssl-91app-io-196811564.ap-northeast-1.elb.amazonaws.com.</code>, <code>52.196.80.17</code>, and <code>54.178.248.57</code> as output.</p>
  
  <p>I originally thought that <a href="https://nodejs.org/api/dns.html#dns_dns_resolveany_hostname_callback" rel="noreferrer"><code>dns.resolveAny</code></a> is an equivalent function of <code>nslookup</code> in node.js. But I was wrong.</p>
  
  <p>Because the following code returns <code>Error: queryAny ESERVFAIL www.amagicshop.com.tw</code> error.</p>
  
  <pre><code>const { Resolver } = require('dns')
  const resolver = new Resolver()
  resolver.setServers(['8.8.8.8'])
  
  resolver.resolveAny('www.amagicshop.com.tw', (err, result) =&gt; {
    if (err) {
      console.error(`error: ${err}`)
    } else {
      console.log(`result:  ${JSON.stringify(result)}`)
    }
  })
  </code></pre>
  
  <p>The result is different from the result of <code>nslookup</code>.</p>
  
  <p>Maybe I have to implement a function which combines <code>resolveCname</code> and <code>resolve4</code> so that I can achieve what I want.</p>