【问题标题】:dnspython not updated when changing resolv.conf更改 resolv.conf 时未更新 dnspython
【发布时间】:2016-06-13 14:32:02
【问题描述】:

这个sn-p完美运行

import dns
import dns.resolver

default = dns.resolver.get_default_resolver()
nameserver = default.nameservers[0]

除了如果我手动更改 /etc/resolv.conf 并再次调用 get_default_resolver 函数,它不会给我带来更新的地址。我需要重启python控制台才能看到更改效果。

我错过了什么?我应该使用同一个库对 resolv.conf 进行更改吗?

提前致谢,

【问题讨论】:

    标签: python dns dnspython


    【解决方案1】:

    如果您在基于非 Debian 的 Linux 上并使用 glibc,那么您必须注意 glibc 缓存 resolv.conf 并且除非明确告知,否则不会再查看它。本质上,如果 resolv.conf 已更改并且需要通过调用 __res_init 重新加载,这取决于您的应用程序。详情请参阅Python not getting IP if cable connected after script has startedhttps://sourceware.org/bugzilla/show_bug.cgi?id=984

    【讨论】:

      猜你喜欢
      • 2017-05-05
      • 2017-08-18
      • 2018-07-22
      • 2013-08-15
      • 2014-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 2021-11-13
      相关资源
      最近更新 更多