如何在没有警告的情况下执行resolvconf?

Bul*_* M. 1 network-manager networking dns resolvconf

我配置了 NetworkManager,以便它/etc/resolv.conf在其目录中维护到文件的符号链接-/var/run/NetworkManager/resolv.conf

ls -l /etc/resolv.conf
... /etc/resolv.conf -> /var/run/NetworkManager/resolv.conf
Run Code Online (Sandbox Code Playgroud)

Resolvconf 尝试配置 DNS:

resolvconf -u
/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf
Run Code Online (Sandbox Code Playgroud)

它与 NetworkManager 的设置相矛盾。如何摆脱这个警告并在没有冲突的情况下设置 NetworkManager 和 resolvconf?

Sta*_*hai 5

首先这是一个警告
以下是resolvconf 手册页中针对您的问题的方法:

Normally  the  resolvconf  program is run only by network interface configuration programs
such as ifup(8),  ifdown,  NetworkManager(8),  dhclient(8),  and  pppd(8);  and  by  local
nameservers  such  as  dnsmasq(8).  These programs obtain nameserver information from some
source and push it to resolvconf.
...
To  make  the  resolver  use  this  dynamically  generated resolver configuration file the
administrator   should   ensure   that   /etc/resolv.conf   is   a   symbolic   link    to
/run/resolvconf/resolv.conf.   This  link  is  normally  created  on  installation  of the
resolvconf package.  The link is never modified by the resolvconf program itself.  If  you
find  that  /etc/resolv.conf is not being updated, please check to make sure that the link
is intact.
Run Code Online (Sandbox Code Playgroud)

因此,为了摆脱警告,您需要做的是重新创建符号链接,您有两个选项:

  1. 您可以根据手册页重新创建符号链接

    rm -f /etc/resolv.conf # Delete actual file/symlink 
    ln -s /run/resolvconf/resolv.conf /etc/resolv.conf # recreate the symlink
    
    Run Code Online (Sandbox Code Playgroud)

    您需要指向正确的文件:/run/resolvconf/resolv.conf,而不是/var/run/NetworkManager/resolv.conf.

  2. 使用 REPORT_ABSENT_SYMLINK 选项告诉 resolvconf 不要向您显示警告:

    echo 'REPORT_ABSENT_SYMLINK="no"' >> /etc/default/resolvconf
    
    Run Code Online (Sandbox Code Playgroud)