I am having an issue where DHCP (I though as I read in other similar topics) is clearing the /etc/resolv.conf file on each boot. I am not sure about how to deal with this since the post I have found (1, 2 and some others) are for Debian based distros or other but not Fedora.

This is the output of ifcfg-enp0s31f6 so for sure is DHCP:

cat /etc/sysconfig/network-scripts/ifcfg-enp0s31f6 

In the other side I don't know if Network Manager is doing something else around this.

Update: Content of NetworkManager.conf (I have removed the comments since are useless)

$ cat /etc/NetworkManager/NetworkManager.conf 


Can I get some help with this? It's annonying be setting up the file once and once on every reboot.


After a month I'm still having the same issue where file gets deleted by "something".

Here is the steps I did follow in order to make a fresh test:

  • Reboot the PC
  • After PC gets restarted open a terminal and try to ping Google servers of course without success:

    $ ping google.com
    ping: google.com: Name or service not known
  • Check the network configuration were all seems to be fine:

    $ cat /etc/sysconfig/network-scripts/ifcfg-enp0s31f6 
  • Restart the network service:

    $ sudo service network restart
    [sudo] password for <current_user>: 
    Restarting network (via systemctl):                        [  OK  ]
  • Try to ping Google servers again, with no success:

    $ ping google.com
    ping: google.com: Name or service not known
  • Check for file /etc/resolv.conf:

    $ cat /etc/resolv.conf 
    cat: /etc/resolv.conf: No such file or directory
  • File doesn't exists anymore - and this is the problem something is deleting it on every reboot

  • Create the file and add the content of DNS:

    $ sudo nano /etc/resolv.conf 
  • Ping Google servers this time with success:

    $ ping google.com
    PING google.com ( 56(84) bytes of data.
    64 bytes from mia07s35-in-f110.1e100.net ( icmp_seq=1 ttl=57 time=3.87 ms

Any ideas in what could be happening here?

  • 3
    may PEERDNS=no help you Nov 15, 2016 at 15:11
  • @IporSircer no, I have changed the value and restart the PC, same result, no DNS information. BTW do I need to restart the PC or service network restart would be enough?
    – ReynierPM
    Nov 15, 2016 at 15:20
  • Try chattr +i /etc/resolv.conf
    – GAD3R
    Nov 16, 2016 at 19:02
  • @GAD3R not working: chattr: Operation not supported while reading flags on /etc/resolv.conf
    – ReynierPM
    Nov 16, 2016 at 19:37
  • Which Fedora version (and Spin/Edition) are you using?
    – mattdm
    Nov 24, 2016 at 18:49

11 Answers 11


In my experience, /etc/resolv.conf gets regenerated on boot, so any manual changes to it get reset.

To work around this, you can create /etc/resolv.conf.head (or .tail depending on which end of the file you want to add to) and insert the custom settings you want in there (usually nameserver changes). Then the contents of that file gets added automatically when /etc/resolv.conf is generated by NetworkManager (or whichever service is in charge of the file on your system).

If that doesn't work, you can modify /etc/resolvconf/resolv.conf.d/base -- it stores the "default" content for /etc/resolv.conf.

  • 1
    This workaroudnd isn't working either, I've tried and after restart /etc/resolv.conf is empty
    – ReynierPM
    Nov 28, 2016 at 13:21

I think you were right on track.

It's working for me now, but I didn't do the:


on the:


After I restarted the network manager, it automatically created the resolv:

sudo service NetworkManager restart

I rebooted and it still worked.


I had the same problem. It was soved by installing the resolvconf package. Since I am on Debian I can not test, but may help this tip:

  1. open (or create) as sudo: /etc/dhcp/dhclient.conf

  2. add: prepend domain-name-servers;

  • I was facing this problem for many months now. I tried different solutions. Nothing solved the problem. I just installed resolvconf package according to your suggestion. It worked! Sep 15, 2021 at 22:16

"Have you tried setting your resolv.conf file to have immutability after putting whatever content you want?."

pretty sure this keeps the /etc/dhcp/dhclient.conf from doing its job and your DNS never resolves anyway. At best this is frustrating and at worst freezes things up as your computer continuously tries to run that file and establish a connection. I think the key is in editing "/etc/dhcp/dhclient.conf" instead of resolv.conf directly, as that is the file that writes to resolv.conf on reboot.

  • Please edit your post to focus on your suggestion (i.e., the last sentence of your answer) and de-emphasize your critique of the other answer. Aug 11, 2018 at 16:38

First You must sure resolvconf service active.

sudo service resolvconf status   

Active: active (exited) since

If the service active remove resolvconf:

sudo apt-get purge resolvconf

Then if after remove or this is not active or service not found:

sudo apt-get update
sudo apt-get install resolvconf

Then restart service:

sudo service resolvconf restart

now see the /etc/resolv.conf:

cat /etc/resolv.conf 

Must be exists:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN # is the systemd-resolved stub resolver. # run "systemd-resolve --status" to see details about the actual nameservers.


  • sudo systemctl enable resolvconf.service to make sure it would run up after reboot Jun 5 at 6:45

Probably NetworkManager is configuring resolve.conf. if you don't want that, change rc-manager setting in NetworkManager.conf. See man NetworkManager.conf.

  • 1
    Nop, that's not the problem. I am reading this in docs none: NetworkManager will not modify resolv.conf. This implies rc-managerunmanaged and I am seeing this on /etc/NetworkManager/NetworkManager.conf [main] dns=none
    – ReynierPM
    Nov 22, 2016 at 13:19

To prevent resolv.conf to be update at boot time, you should make the following changes:

Change PEERDNS=yes to PEERDNS=no


This will prevent network service from updating /etc/resolv.conf with the DNS servers received from a DHCP server.

mentioned on @Ipor Sircer comment's

  • 1
    PEERDNS is set to no (see OP) now will BOOTPROTO=static change to static IP address instead of dynamic? If that's the case then this will not fix the issue.
    – ReynierPM
    Nov 28, 2016 at 13:17
  • @ReynierPM right
    – GAD3R
    Nov 28, 2016 at 13:18
  • I am not using NM at all, I mean is a tool in the GUI but I never touch it, can I disable it to prevent this behavior? People using DHCP on the same office gets DNS and Internet connection so I don't know what is happening here and I am tempted to disable NM, what do you think?
    – ReynierPM
    Nov 28, 2016 at 13:27
  • @ReynierPM can you add the contents of NetworkManager.conf
    – GAD3R
    Nov 28, 2016 at 13:40
  • Done, in the OP
    – ReynierPM
    Nov 28, 2016 at 13:46

I got the same problem when I install Debian 9.5 with GUI today. I do not have this problem when I install it without GUI. Finally, I found the solution from this link https://wiki.debian.org/resolv.conf. The DHCP started automatically even I set network manually when I was installing it. You should disable the DHCP to stop this problem.

echo 'make_resolv_conf() { :; }' > /etc/dhcp/dhclient-enter-hooks.d/leave_my_resolv_conf_alone
chmod 755 /etc/dhcp/dhclient-enter-hooks.d/leave_my_resolv_conf_alone

If that does not solve your problem, then I added a new line in the DHCP client file.

vi /etc/dhcp/dhclient.conf

prepend domain-name-servers;

Next, I remove the resolvconf and network-manger packages.

apt-get --purge remove resolvconf network-manager

Finally, if you still got the problem, you should setup your resolv.conf file and then lock this file by the following command. (It does not work if your resolv.conf is a symbolic link.)

chattr +i /etc/resolv.conf

I have had the same problem on

Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster .

On my system I am using dnsmasq for several reasons.

Therefore the DNS for system apps is localhost aka

In the dnsmasq then I redirect some queries to the external DNS resolvers and some I resolve locally.

Long story short:

Because I was using static IP settings for my NIC, there was no setting made for DNS servers in the GUI of NetworkManager.

Therefore no resolv.conf was being generated.

Although most services were working, some were not.

The solution to make ALL services work was to enter as DNS Server in the GUI of NetworkManager and restart that Service.

Kind regards.


To me, in Debian 10, it was connman. Indeed:`

$> ls -l /etc
.. .. 
resolv.conf -> /run/connman/resolv.conf 

I disabled connman, removed the file resolv.conf and re-created it as a regular file. After reboot finally it is still there.


Have you tried setting your resolv.conf file to have immutability after putting whatever content you want?.

You may want to use chattr +i /etc/resolv.conf or with sudo.

By doing this we avoid overwrite.

Unless it is getting deleted, it might give initial insight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.