Dns

試圖理解 /etc/resolv.conf

  • May 28, 2020

我正在嘗試了解/etc/resolv.conflinux 系統中文件中的條目。

該文件包含關鍵字和值的列表。

這是以下內容的範例/etc/resolv.conf

domain xxx.net
search xxx.net
nameserver 192.168.1.254

我了解該nameserver條目是作業系統用於解析 DNS 查詢的預設名稱伺服器。

我的問題是domainsearchkeyworks 及其相關值是什麼?

您可以在頁面中獲取您要查找的資訊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名稱必須明確列出。

引用自:https://unix.stackexchange.com/questions/589513