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

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

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

ls -l /etc/resolv.conf
... /etc/resolv.conf -> /var/run/NetworkManager/resolv.conf

Resolvconf 尝试配置 DNS:

resolvconf -u
/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf

它与 NetworkManager 的设置相矛盾。如何摆脱此警告并设置 NetworkManager 和 resolvconf 而不发生冲突?

答案1

首先,这是一个警告
以下是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.

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

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

    rm -f /etc/resolv.conf # Delete actual file/symlink 
    ln -s /run/resolvconf/resolv.conf /etc/resolv.conf # recreate the symlink
    

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

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

    echo 'REPORT_ABSENT_SYMLINK="no"' >> /etc/default/resolvconf
    

相关内容