【问题标题】:Dnspython can't resolve anythingDnspython 无法解决任何问题
【发布时间】:2020-12-13 04:30:13
【问题描述】:

我的示例代码是

import dnspython as dns
import dns.resolver

result = dns.resolver.query('google.com', 'A')
for ipval in result:
    print('IP', ipval.to_text())

这给了我错误 dns.resolver.NoResolverConfiguration: Resolver configuration could not be read or specified no nameservers.

/etc/resolv.conf 包含“1.1.1.1”,没有其他内容,netplan 名称服务器也设置为 1.1.1.1。

机器在 ubuntu 20.04 上运行 python 3.8.5。

为什么会出现这个错误,我该如何解决?

【问题讨论】:

    标签: python ubuntu dns


    【解决方案1】:

    想通了!

    巨大的手掌。我忘了把名称服务器 1.1.1.1 而不是 1.1.1.1 放在 /etc/resolv.conf

    所以,确实,配置是错误的。

    【讨论】:

      猜你喜欢
      • 2013-03-21
      • 2018-05-24
      • 1970-01-01
      • 2022-01-10
      • 2016-10-16
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多