mDNS 或多播 DNS 服务

mDNS 或多播 DNS 服务

有 Ubuntu 16.04 LTS 版本。根据任务应该安装 BIND 作为 DNS 服务器。我注意到 nsswitch.conf 中有:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

您能解释一下是什么意思mdns4_minimal以及mdns4如何让系统使用本地 BIND 实例来解析 DNS 查询吗?

是的,我知道如何启动/停止 BIND。

systemctl enable bind9
systemctl start/stop bind9.

答案1

mDNS 或多播 DNS 服务

它由阿瓦希/你好守护进程,即使没有中央 DNS,它也能让小型网络计算机使用名称。它默认使用域.local

  • 如果你不使用.localDNS 服务器,则在 mDNS 后设置 DNS nsswitch.conf(默认)

    hosts: files mdns4_minimal dns [NOTFOUND=return] mdns4
    

    否则.local由你的 DNS 服务器使用(对 mdns 服务无用)

    hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4
    

mdns4_minimal 和 mdns4 有什么区别?

为了回答你,最好让我知道如何收集这些信息并自己学习:)(##用于评论以告知其下方命令的目的)

## Update "locate" database
~$ sudo updatedb
## Search for file with "mdns4_minimal" in its name
~$ locate mdns4_minimal
/lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2

## Look for which package installs that file
~$ dpkg -S /lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2
libnss-mdns:amd64: /lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2

## List all files from same package
~$ dpkg -L libnss-mdns:amd64
/.
/usr
/usr/share
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/libnss-mdns
/usr/share/doc
/usr/share/doc/libnss-mdns
/usr/share/doc/libnss-mdns/copyright
/usr/share/doc/libnss-mdns/README.html
/usr/share/doc/libnss-mdns/README.Debian
/usr/share/doc/libnss-mdns/style.css
/usr/share/doc/libnss-mdns/changelog.Debian.gz
/lib
/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu/libnss_mdns4.so.2
/lib/x86_64-linux-gnu/libnss_mdns_minimal.so.2
/lib/x86_64-linux-gnu/libnss_mdns.so.2
/lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2
/lib/x86_64-linux-gnu/libnss_mdns6.so.2
/lib/x86_64-linux-gnu/libnss_mdns6_minimal.so.2

## "README.html" looks the only documentation there, we open it
~$ xdg-open /usr/share/doc/libnss-mdns/README.html

文档

编译并安装后,nss-mdns您将发现六个新的 NSS 模块/lib

  • libnss_mdns.so.2
  • libnss_mdns4.so.2
  • libnss_mdns6.so.2
  • libnss_mdns_minimal.so.2
  • libnss_mdns4_minimal.so.2
  • libnss_mdns6_minimal.so.2


libnss_mdns.so.2解析 IPv6 和 IPv4 地址、 libnss_mdns4.so.2仅解析 IPv4 地址和libnss_mdns6.so.2仅解析 IPv6 地址。由于大多数 mDNS 响应器仅通过 mDNS 注册本地 IPv4 地址,因此大多数人会希望 libnss_mdns4.so.2专门使用。在这种情况下使用libnss_mdns.so.2libnss_mdns6.so.2会导致解析主机时出现长时间超时,因为大多数现代 Unix/Linux 应用程序首先检查 IPv6 地址,然后查找 IPv4。

libnss_mdns{4,6,}_minimal.so(0.8 版新增)与不带 的版本基本相同_minimal。但它们有一点不同。最小版本将始终拒绝解析不以 结尾的主机名.local或不在 范围内的地址 169.254.x.x(由 IPV4LL/APIPA/RFC3927) 通过将_minimal和普通的 NSS 模块结合起来,我们可以让 mDNS 对 Zeroconf 主机名和地址具有权威性(从而无需因为请求总是失败而给 DNS 服务器造成额外负担),并将其用作其他所有功能的后备。

IPv6 支持

  • files& dnsNSS 模块,除了支持 IPv4 之外,还支持解析 IPv6。
  • 但是,mdns4&mdns4_minimal仅适用于 IPv4。

    相同mdns6mdns6_minimal仅适用于 IPv6。

    mdns支持mdns_minimalIPv4 和 IPv6,但如果网络中仅部署单一 IP 版本,则应避免使用它。因为它会尝试解析为 IPv6,然后回退到 IPv4,这可能会造成额外的延迟。

    顺便说一句,Avahi 当前的默认设置是 IPv4,它是一种分散式服务。因此,要使用 IPv6,所有机器都应重新配置为使用nsswitchIPv6 avahi

[]还有什么类似的吗[NOTFOUND=return]

是的,正如我们所看到的man nsswitch.conf

   An action may also be specified following a service specification.   The  action  modifies
   the  behavior  following  a  result obtained from the preceding data source.  Action items
   take the general form:

       [STATUS=ACTION]
       [!STATUS=ACTION]

   where

       STATUS => success | notfound | unavail | tryagain
       ACTION => return | continue

   The ! negates the test, matching all possible results except the one specified.  The  case
   of the keywords is not significant.

   The  STATUS  value is matched against the result of the lookup function called by the pre‐
   ceding service specification, and can be one of:

       success     No error occurred and the requested entry is returned.  The default action
                   for this condition is "return".

       notfound    The  lookup succeeded, but the requested entry was not found.  The default
                   action for this condition is "continue".

       unavail     The service is permanently unavailable.  This can  mean  either  that  the
                   required file cannot be read, or, for network services, that the server is
                   not available or does not allow queries.  The default action for this con‐
                   dition is "continue".

       tryagain    The  service is temporarily unavailable.  This could mean a file is locked
                   or a server currently cannot accept more connections.  The default  action
                   for this condition is "continue".

   The ACTION value can be one of:

       return      Return  a result now.  Do not call any further lookup functions.  However,
                   for compatibility reasons, if this is the selected action  for  the  group
                   database and the notfound status, and the configuration file does not con‐
                   tain the initgroups line, the next lookup function is always called, with‐
                   out affecting the search result.

       continue    Call the next lookup function.

相关问题:

相关内容