Ubuntu系统重启后/etc/resolv.conf内容丢失
2017-04-22 10:53
681 查看
简介
简要介绍如何解决Ubuntu系统重启后/etc/resolv.conf内容丢失问题,或者说解决永久保存/etc/resolv.conf配置问题。方案1 通过/etc/network/interfaces配置
通过向/etc/network/interfaces接口配置文件追加dns-nameserver和dns-search项来永久保存配置,保存完成后执行"sudo service networing restart"重启网络来触发更新/etc/resolv.conf文件。The ifup program can be used to configure network interfaces according to settings in /etc/network/interfaces. To make ifup push nameserver information to resolvconf when it configures an interface the administrator must add dns- option lines to the relevant iface stanza in interfaces(5). The following option names are accepted: dns-nameserver, dns-search, and dns-sortlist. To add a nameserver IP address, add an option line consisting of dns-nameserver and the address. To add multiple name server addresses, include multiple such dns-nameserver lines. dns-nameserver 192.168.1.254 dns-nameserver 8.8.8.8 To add search domain names, add a line beginning with dns-search. dns-search foo.org bar.com The dns-nameservers option is also accepted and, unlike dns-nameserver, can be given multiple arguments, separated by spaces. The dns-domain option is deprecated in favor of dns-search. The resulting stanza might look like the following example. iface eth0 inet static address 192.168.1.3 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameserver 192.168.1.254 dns-nameserver 8.8.8.8 dns-search foo.org bar.com
方案2 通过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/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
总结
以上两种配置方式均可实现/etc/resolv.conf配置永久保存功能,更具体的信息可以查看"man resolvconf"手册。相关文章推荐
- /etc/resolv.conf 的更改在重启后丢失的解决办法
- ubuntu网络重启后或主机重启后,/etc/resolv.conf恢复原样的解决办法
- 解决Ubuntu系统的每次开机重启后,resolv.conf清空的问题和DNS域名解析问题
- /etc/resolv.conf 的更改在重启后丢失
- Ubuntu 12.04 修改/etc/resolv.conf重启后还原成修改前状态解决办法
- /etc/resolv.conf 的更改在重启后丢失的解决办法
- Ubuntu 12.04重启后丢失resolv.conf问题
- Ubuntu 12.04 每次重启后,/etc/resolv.conf里面设置的nameserver就被清空
- /etc/resolv.conf 的更改在重启后丢失的解决办法
- ubuntu网络重启后或主机重启后,/etc/resolv.conf恢复原样的解决办法
- /etc/resolv.conf 的更改在重启后丢失的解决办法
- Ubuntu 12.04 修改/etc/resolv.conf重启后还原成修改前状态解决办法
- /etc/resolv.conf 的更改在重启后丢失的解决办法
- 每次ubuntu12.04重启后,/etc/resolv.conf被重写为空或127.0.0.1
- /etc/resolv.conf中DNS丢失
- Ubuntu 12.04重启后resolv.conf清空的问题
- Ubuntu中/etc/resolv.conf
- [转]resolv.conf 配置信息重启后丢失解决方法
- Ubuntu 12.04解决重启后resolv.conf清空的问题
- Ubuntu 11.04修改resolv.conf文件重启后还原成修改前状态解决办法