How to avoid overwriting of /etc/resolv.conf with dhcp ???
-
- Offline
- 1 year 2 months ago
- 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
To avoid overwriting /etc/resolv.conf, you must create the /etc/udhcpc/udhcpc.conf file with this content:
You can look at /etc/init.d/networking and /usr/share/udhcpc/default.script to see what happens at network startup.
Merci bien!