1

This question already has an answer here:

I've built a custom linux system using Yocto. It uses busybox. I have most everything working, except I can't have a static dns resolver address because /etc/resolv.conf is being deleted on every boot, and replaced with a link to /var/run/resolv.conf.

I think this is being caused by a script called /etc/volatile.cache. I've deleted this script, but I think another script /etc/init.d/populate-volatile.sh recreates it every time.

Certainly I could add my own script, something like /etc/rc5.d/S90set-resolv that writes a value to resolv.conf, but that seems like an extremely strange way to do it.

Does anybody know what is going on here? What is the correct way to set a nameserver address in this situation?

marked as duplicate by Kusalananda, Archemar, Jesse_b, elbarna, meuh Mar 18 '18 at 9:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    As a workaround, make the file immutable (chattr +i /etc/resolv.conf), and then look for distraught shouting in the system logs. – DopeGhoti Mar 16 '18 at 23:01
  • 1
    Uninstall resolvconf, in server settings is just an hindrance. – Rui F Ribeiro Mar 16 '18 at 23:03
  • 1
    From what I remember, /etc/resolv.conf is supposed to be a symlink to /var/run/resolv.conf Does /var/run/resolv.conf exist when you boot? – saleetzo Mar 16 '18 at 23:06
  • DopeGhoti, that may be a last resort, but I can't imagine that is the right way to do it. There really ought to be a simple way to configure a static address. – Dave Mar 16 '18 at 23:34
  • Rui, resolvconf is not installed – Dave Mar 16 '18 at 23:35
0

by the way things are not going well at all, it's not even a friend, but you should see it well before you leave, thus applying "chattr + i" files to the system, I think we should look for a solution to the problem that sometimes be something so simple that is in our face and we can not fill because we are nervous wanting to impose our will on the system, sometimes a little script even works miracles when well executed in the network, but apparently you do not want this and by the way is not or is studying to be a systems administrator, sorry! But if you'd rather get nervous and perform these nonsense tricks of this kind on the system okay after all, it's not on my system, sorry to leave it you angry at that! Instead of doing this! to use the 'chattr' command configure, edit the 'interfaces' file, which is usually in the /etc/network/ folder and add/change the dns-nameserver options with the nameserver ip you want. if these options are not in the file you can add them as small examples:

-Sample: just edit the "/etc/network/interfaces" file.

   auto lo
   iface lo inet loopback
   iface lo inet6 loopback
   iface eth0 inet static

   dns-nameserver 192.168.1.1 <= Your IP address here.
   dns-nameserver 8.8.8.8
   dns-nameserver 8.8.4.4

-Save the file and reboot the network ...


In your case you just want to set the IP address of the servers, set only the following to the end of the interfaces file.

   dns-nameserver 8.8.4.4
   dns-nameserver 8.8.8.8

Here is an example/sample that is used here.

    auto lo
    iface lo inet loopback
    iface lo inet6 loopback
    iface eth0 inet static

            address 192.168.1.4/24
            netmask 255.255.255.0
            gateway 192.168.1.1

   dns-nameserver 192.168.1.4
   dns-nameserver 8.8.4.4
   dns-nameserver 8.8.8.8

Here's just a small sample, so you better understand how the system creates your resvol.conf file with each boot.

If you just want to set the addresses of your DNS servers in the revsolv.conf file just set the dns-nameserver in the rest you can leave it as it is, do not need to change, just set the "dns-nameserver" and save, boot and you will see that from now on your file resolv.conf will always come with the dns-nameserver that you have defined in this file.

  • I get the following error if I try and have multiple dns-nameserver entries: ifup: duplicate option "dns-nameserver". If I just add one entry, it fails to load in to resolv.conf (can't ping anything). – Dave Mar 16 '18 at 23:46
  • This is why I say not to impose your will to the system with "chattr + i" because it only makes the situation worse ... now you will have to take a little look at the logs, remember some change you can have done to see if it finds the point where the system looked like this ... – Joke Sr. OK Mar 17 '18 at 0:03
  • I haven't done chattr +i, and this is a freshly built system. I haven't changed anything. – Dave Mar 17 '18 at 0:11
  • What you have defined in your "/etc/resolv.conf" file and what you have defined in your "/etc/network/interfaces" file? – Joke Sr. OK Mar 17 '18 at 0:25
  • Minor nitpicking: if you have an internal DNS server with local zones, you do not want to give your DNS resolver servers with different views of the world. – Rui F Ribeiro Mar 17 '18 at 5:12

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