resolv.conf在重启时重写

时间:2015-03-04 17:13:11

标签: linux unix dns fedora-21

我正在配置fedora 21服务器,我根据以下LINK

设置了静态ip和dns

我正在使用

编辑文件
vi /etc/resolv.conf

然后把我的dns就像那里提到的那样。 一切都很好。 但是在重新启动后,文件被其原始内容覆盖:

# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com

发生了什么以及如何阻止这种情况发生?

3 个答案:

答案 0 :(得分:0)

NetworkManager正在覆盖它。您可以将其关闭并进入“手动”模式,其中包含一些教程:http://xmodulo.com/disable-network-manager-linux.html

答案 1 :(得分:0)

在fedora 26下,man NetworkManager.conf,它说:

rc-manager
           Set the resolv.conf management mode. The default value depends on NetworkManager build options, and this version of NetworkManager was build with a default of "symlink". Regardless of this
           setting, NetworkManager will always write resolv.conf to its runtime state directory /var/run/NetworkManager/resolv.conf.

           symlink: If /etc/resolv.conf is a regular file, NetworkManager will replace the file on update. If /etc/resolv.conf is instead a symlink, NetworkManager will leave it alone. Unless the symlink
           points to the internal file /var/run/NetworkManager/resolv.conf, in which case the symlink will be updated to emit an inotify notification. This allows the user to conveniently instruct
           NetworkManager not to manage /etc/resolv.conf by replacing it with a symlink.

           file: NetworkManager will write /etc/resolv.conf as file. If it finds a symlink, it will follow the symlink and update the target instead.

           resolvconf: NetworkManager will run resolvconf to update the DNS configuration.

           netconfig: NetworkManager will run netconfig to update the DNS configuration.

           unmanaged: don't touch /etc/resolv.conf.

           none: deprecated alias for symlink.

似乎无需更改任何配置文件。

我只是在那里放了一个符号链接,然后就可以了。

答案 2 :(得分:0)

使用以下命令来防止resolv.conf或任何文件在重启后被覆盖

chattr -V +i filename

例如:chattr -V +i /etc/resolv.conf

要还原更改,请使用以下命令:

chattr -i filename-重新启用插入文件

chattr(更改属性)是一个命令行Linux实用程序,即使您以root用户身份登录,该实用程序仍可用于为Linux系统中的文件设置/取消设置某些属性,以确保意外删除或修改重要文件和文件夹。用户。