我试图理解/etc/resolv.conf
Linux 系统中文件中的条目。
该文件包含关键字和值的列表。
这是内容的示例/etc/resolv.conf
:
domain xxx.net
search xxx.net
nameserver 192.168.1.254
据我所知,该nameserver
条目是操作系统用来解析 DNS 查询的默认名称服务器。
我的问题是domain
和search
keyworks 及其相关值是什么?
答案1
您可以在以下页面中获取您要查找的信息man
:
man resolv.conf
...
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 deter‐
mined 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.
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. This
may be changed by listing the desired domain search path follow‐
ing the search keyword with spaces or tabs separating the names.
Resolver queries having fewer than ndots dots (default is 1) in
them will be attempted using each component of the search path
in turn until a match is found. For environments with multiple
subdomains please read options ndots:n below to avoid man-in-
the-middle attacks and unnecessary traffic for the root-dns-
servers. Note that this process may be slow and will generate a
lot of network traffic if the servers for the listed domains are
not local, and that queries will time out if no server is avail‐
able for one of the domains.
The search list is currently limited to six domains with a total
of 256 characters.
因此,在您拥有domain xxx.net
它的情况下,意味着您可以引用该域中的内容而不列出它:ping server_name.xxx.net
或者ping server_name
两者都会正确解析。
search
domain
是在失败后尝试解析短名称的其他域的列表。主要区别在于,如果没有domain
列出,它将根据本地主机名进行猜测,search
名称必须需要显式列出。