How to avoid overwriting of /etc/resolv.conf with dhcp ???

3 posts / 0 new
Last post
#1 Mon, 2015-03-16 23:29
ALPINISTA
  • ALPINISTA's picture
  • Offline
  • Last seen: 1 year 2 months ago
  • Joined: 2015-03-16

Hi,

from the wiki I read that warning about /etc/resolv.conf being overwritten in every case with dhcp.

Of course I am running in exactly this situation, I need dhcp but the nameserver information is not available so /etc/resolv.conf is empty.

It seems that an extra dns-nameservers in /etc/network/interfaces does not work like expected:

auto eth0
iface eth0 inet dhcp
dns-nameservers 8.8.8.8

This does not set the nameserver information.

So I would like to have a little script executed on system start:

#!/bin/sh
echo "nameserver 8.8.8.8" > /etc/resolv.conf

but where do I have to put this script? I created a file with the above content as

/etc/local.d/resolv.start 

and made it executable, but it does not seem to do anything on boot.

Yes, I would like to avoid to make this an init script just for adding one line to resolv.conf...

Alternatively I would like to avoid having the /etc/resolv.conf overwritten, is this possible?

Where can I read more about what exactly happens at network startup?

Thanks for your attention!
ALPINISTA

Tue, 2015-03-17 08:51
AmatCoder
  • AmatCoder's picture
  • Offline
  • Last seen: 1 year 4 months ago
  • Joined: 2013-10-18

To avoid overwriting /etc/resolv.conf, you must create the /etc/udhcpc/udhcpc.conf file with this content:

RESOLV_CONF="NO"

You can look at /etc/init.d/networking and /usr/share/udhcpc/default.script to see what happens at network startup.

Wed, 2015-03-18 01:53 (Reply to #2)
ALPINISTA
  • ALPINISTA's picture
  • Offline
  • Last seen: 1 year 2 months ago
  • Joined: 2015-03-16

Merci bien!

Log in or register to post comments