0

我正在配置一个 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

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

4

3 回答 3

0

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

于 2015-03-04T20:02:23.343 回答
0

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

chattr -V +i filename

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

要恢复更改,请使用以下命令:

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

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

于 2019-10-15T18:54:55.477 回答
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.

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

我只是在那里放了一个符号链接,它就可以工作。

于 2017-12-12T03:43:38.837 回答