4

I cannot use apt update as every reboot my sudo vim /etc/resolv.conf file resets to the below

# Generated by resolvconf
search home
nameserver 127.0.0.1

I have tried to change the nameserver to a proper DNS but it resets every reboot? How can I fix this?

  • The file is automatically generated. If this is missing it indicates some problem in your networking setup. You should specify what you have done. – Milliways Jan 29 '18 at 0:01
1

As written in the first line of /etc/resolv.conf it is generated by resolvconf. If you want to set a static domain name server you have to uncomment in /etc/dhcpcd.conf the line:

#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

and set it to your name server and reboot. Maybe you have also to stop asking for a domain name server from your dhcp server. You can try to modify the line:

option domain_name_servers, domain_name, domain_search, host_name

to

option domain_name, domain_search, host_name
  • No. This file does not exist, and creating it doesn't change anything. – Daniel F Jan 16 at 16:57
  • @DanielF Of course does it exist. This is an accepted answer. As seen from the tags of the question we are talking about raspbian-stretch. So please use a default unmodified image from it and you will find /etc/dhcpcd.conf and /etc/resolv.conf because dhcpcd is the default networking management for Raspbian. If you have a problem with your setup then please open a new question. – Ingo Jan 16 at 18:43
0
  1. Open the following file:

    $ sudo vim /etc/resolvconf/resolv.conf.d/base

  2. Put your nameserver list in the file like those:

    nameserver 8.8.8.8 nameserver 8.8.4.4

  3. Update resolvconf with the following command:

    $ sudo resolvconf -u

  • 1
    The file doesn't exist and I cannot create it either with sudo or directly as root – eekfonky Jan 28 '18 at 20:15
  • I also know the trick with editing /etc/resolvconf/resolv.conf.d/base on my Ubuntu Server machines, but Raspbians resolvconf seems to work different. Even creating the missing resolv.conf.d directory and base directory and setting the same file permissions than on my Ubuntu permissions did not do the trick. – Stefan Wegener Apr 23 at 9:25

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.