我该如何理解`/etc/resolv.conf` 的格式?

Tim*_*Tim 5 dns resolv.conf

我该如何理解 的格式/etc/resolv.conf

$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
search fios-router.home
Run Code Online (Sandbox Code Playgroud)

/etc/resolve.conf 的联机帮助页说

不同的配置选项是:

   nameserver Name server IP address

          Internet address of a name server that the resolver should
          query...
Run Code Online (Sandbox Code Playgroud)

那么是否nameserver 127.0.0.53意味着我的本地机器正在运行一个 IP 地址为 127.0.0.53 的 DNS 服务器?我怎样才能找到它的过程?

   domain Local domain name.

          Most queries for names within this domain can use short names
          relative to the local domain.  If set to '.', the root domain
          is considered.  If no domain entry is present, the domain is
          determined from the local hostname returned by gethostname(2);
          the domain part is taken to be everything after the first '.'.
          Finally, if the hostname does not contain a domain part, the
          root domain is assumed.
Run Code Online (Sandbox Code Playgroud)

这部分是什么意思?上面只是提到了可以设置什么值,并没有解释/etc/resolv.conf中的这部分是什么意思。为什么我的 /etc/resolv.conf 没有这部分?

   search Search list for host-name lookup.

          The search list is normally determined from the local domain
          name; by default, it contains only the local domain name.
Run Code Online (Sandbox Code Playgroud)

这部分是什么意思?是什么search fios-router.home在我的/etc/resolv.conf是什么意思?

谢谢。

Tsu*_*oku 5

/etc/resolv.confDNS 客户端的主要配置文件,因此它的存在并不意味着您正在运行 DNS服务器

它的主要目的是列出 DNS 服务器的 IP 地址,在您的情况下:

名称服务器 127.0.0.53

  • type 条目nameserver告诉主机要使用哪个 DNS 服务器。
  • 一个类型的条目domain(如果存在)告诉系统它在哪个域中。这允许通过它的主机名来寻址。(回复评论补充:主机名是网络中计算机的名称。在许多系统上,您可以在命令提示符中看到主机名;如果没有,您可以使用命令找到它hostname。)
  • 类型条目search(如果存在)将允许来自不同域的计算机通过各自的主机名相互寻址。

该文件现在通常由NetworkManager(例如,在我的系统上,文件以注释“由 NetworkManager 生成”开头)或由systemd-resolved.

systemd-resolved

是为本地应用程序提供网络名称解析的系统服务。它实现了一个缓存和验证 DNS/DNSSEC 存根解析器,以及一个 LLMNR 和 MulticastDNS 解析器和响应器。

同样根据systemd-resolved 的联机帮助页,该地址127.0.0.53是“本地 DNS 存根侦听器”。在相关的 Stack Exchange 站点上,存在关于如何更改此设置的问题,因为该文件/etc/resolv.conf是自动生成的。见例如


Rad*_*ici 2

search fios-router.home部分是最后一个可解析的域,即您的路由器(iirc Verizon)。

127.0.0.53 是名称服务器的 IP 地址,因此您的假设是正确的。