我正在使用带有 avahi 命令行工具(版本 0.6.31)的 Fedora 18
我使用 avahi-resolve-host-name 来发现我子网上单元的 IP 地址,用于开发期间的测试目的。我使用 Wireshark 监控请求和响应。在一次成功的请求和响应后,Wireshark 上不再显示任何请求,但该工具仍会返回一个 IP 地址。计算机/avahi 守护程序/其他东西是否可能正在“缓存”结果?
问题:我希望在每次调用 avahi-resolve-host-name 时发送请求数据包。这可能吗?
原因:可以这么说,我遇到了“误报”。我尝试解析“test1.local”,我得到了一个结果 IP,但该单元不再位于该 IP。我希望每次都发送请求,这样我就可以避免看到 IP 地址不正确的单元。
最佳答案
我知道我回答你的问题有点晚了,但我会留下一个通用的答案,以防其他人偶然发现这个问题。
我的答案是基于 avahi-0.6.32_rc。
Is it possible the computer/avahi daemon/something else is 'caching' the result?
是的,avahi-daemon 正在缓存查找结果。虽然这似乎没有在功能中明确列出,但 avahi-daemon(8)
联机帮助页提示它:
The daemon [...] provides two IPC APIs for local programs to make use of the mDNS record cache the avahi-daemon maintains.
I wish to send out the request packet with EVERY CALL of avahi-resolve-host-name. Is this possible?
是的,是的。相关选项是 cache-entries-max
(来自 avahi-daemon.conf(5)
):
cache-entries-max=
Takes an unsigned integer specifying how many resource records are cached per interface. Bigger values allow mDNS work correctly in large LANs but also increase memory consumption.
要达到预期的效果,您可以简单地设置:
cache-entries-max=0
这将完全禁用缓存并强制 avahi-daemon 在每次请求时重新发出 MDNS 数据包,因此您可以监控它们。
但是,我在这里应该注意,这也会使 avahi 对于正常使用来说几乎毫无用处。虽然 avahi-daemon 将发出查找数据包,但它无法存储结果和 avahi-resolve-host-name
的每次调用(以及其他命令行工具,nss-mdns, D-Bus API…) 会失败。
关于linux - Avahi 主机名解析 : Is it caching somewhere?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18388334/