【问题标题】:Does Golang's net.LookupHost() use all DNS servers in "/etc/resolv.conf"?Golang 的 net.LookupHost() 是否使用“/etc/resolv.conf”中的所有 DNS 服务器?
【发布时间】:2016-06-16 19:46:04
【问题描述】:

我有一个应用程序,它是用 Go 编写的,它使用这个函数,但它总是无法解析 DNS 名称。我可以使用其他应用程序很好地解析服务器上的 DNS 名称,但不能使用使用此功能的基于 Go 的应用程序。

【问题讨论】:

  • 尝试使用GODEBUG=netdns=cgo运行应用程序

标签: linux go dns


【解决方案1】:

如有疑问,请“使用来源,卢克”。阅读 dnsclient_unix.go 会发现它会遍历所有已配置的服务器。

但请注意:

// If answer errored for rcodes dnsRcodeSuccess or dnsRcodeNameError,
// it means the response in msg was not useful and trying another
// server probably won't help. Return now in those cases.
// TODO: indicate this in a more obvious way, such as a field on DNSError?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    • 2017-04-27
    • 2011-05-23
    • 2020-03-01
    • 2013-05-07
    相关资源
    最近更新 更多