Linux:在Ubuntu上使用resolvconf管理resolv.conf

时间:2020-02-23 14:39:51  来源:igfitidea点击:

最近,Ubuntu引入了" resolvconf",用于管理和维护旧版" /etc/resolv.conf"文件。
如该文件的注释所述,所有手动编辑都将丢失,因此默认情况下,您必须使用resolvconf进行管理。

您将在/etc/resolvconf/resolv.conf.d下找到以下文本文件:

base : used when no data can be found
head : header for resolv.conf
original : backup of resolv.conf
tail : anything in that file will be append to resolv.conf (this is here you should edit or add nameservers)

因此,假设您要添加"名称服务器8.8.8.8"并使其生效,只需修改:

/etc/resolvconf/resolv.conf.d/tail

添加:

nameserver 8.8.8.8

然后使用resolvconf重新生成resolv.conf:

sudo resolvconf -u

现在,您将在/etc/resolv.conf中看到您的更改。