Ubuntu系统重启后/etc/resolv.conf内容丢失的解决方案

时间:2022-10-04 20:35:16
通过resolvconf实现配置
resolvconfig应用可以实现DNS信息管理,可以通过下面的应用来安装此组件:
sudo apt-get install resolvconf
创建/etc/default/resolvconf缺省配置文件,添加相关环境变量
bob@ubuntu:/etc/resolvconf/resolv.conf.d$ cat /etc/default/resolvconf   
TRUNCATE_NAMESERVER_LIST_AFTER_127=no
该环境变量影响保存到/etc/resolv.conf的DNS配置条数。向/etc/resolvconf/resolv.conf.d/base配置文件中添加DNS配置项。
bob@ubuntu:/etc/resolvconf/resolv.conf.d$ cat base  
nameserver 10.220.0.11  
nameserver 10.220.0.12  
search infinera.com
使用下列配置命令使配置生效
sudo resolvconf -u