1

I am configuring a fedora 21 server and I've set the static ip and dns based on the following LINK

I am editing the file using

vi /etc/resolv.conf

and then putting my dns just like it has been mentioned there. Everything is working perfectly fine. But after I reboot, the file is over-written by its original contents :

# 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

What is going on and how to stop this from happening ?

Community
  • 1
  • 1
Priyabrata
  • 1,202
  • 3
  • 19
  • 57

3 Answers3

0

NetworkManager is overwriting it. You can turn it off and go into "manual" mode, some tutorial there: http://xmodulo.com/disable-network-manager-linux.html

jaroslawj
  • 462
  • 2
  • 12
0

under fedora 26, man NetworkManager.conf, it says:

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.

It seems there is no need to change any config file.

I just put a symlink there and it works.

rhinoxi
  • 111
  • 2
  • 6
0

Use the below command to prevent the resolv.conf or any file from overwriting after reboot

chattr -V +i filename

e.g: chattr -V +i /etc/resolv.conf

To Revert Back the Change Use the below Command :

chattr -i filename - to re-enable insert to the file

chattr (Change Attribute) is a command line Linux utility that is used to set/unset certain attributes to a file in Linux system to secure accidental deletion or modification of important files and folders, even though you are logged in as a root user.

Diego Magdaleno
  • 831
  • 8
  • 20