Why golang Lookup*** function can't provide a server parameter?

后端 未结 5 1270
心在旅途
心在旅途 2020-12-14 18:11

For nslookup command, it has nslookup somewhere.com some.dns.server.

However, it seems that golang dnsclient only load config from /

5条回答
  •  死守一世寂寞
    2020-12-14 18:57

    The net.Lookup* functions provide access to the local resolver. While many requests will be answered with information from a DNS server, this is not always the case.

    For instance, LookupHost may return a name from the /etc/hosts file. Or it might use mDNS to resolve a .local name.

    If you want to talk to an arbitrary DNS server rather than the local resolver, then you should use a general purpose DNS client library. As suggested in the comments, https://github.com/miekg/dns might fit your needs.

提交回复
热议问题