Unix & Linux: What overwrites /etc/resolv.conf on every boot?
The Question: I was given the files for a mini linux, that boots directly into firefox. It
works for all it should be doing, only that I do not get an internet
connection.
We have 3 DNS servers in the network, which all work. I can ping them, too. But
when trying to ping google.de or wget google.de I get a bad address error.
nslookup google.de works for some reason.
I tracked the issue down to my resolv.conf on the booted system not having the
same contents as the resolv.conf that I put into the .iso file.
I tried understanding all the factors that go into creating and modifying
resolv.conf. I'm not quite sure I got it all, but I definitely didn't find my
solution there.
So as a last ditch effort, I tried making the resolv.conf file immutable using
:~# chattr +i /etc/resolv.conf
When rebuilding and booting again to my surprise my file was renamed to
resolv.conf~ and in its place was the same standard file that has been haunting
me.
The file contents make me believe it gets the information from the network
itself. When starting the .iso in Virtualbox without internet access, my file
is being kept as it is.
I tried changing /etc/dhcp/dhclient.conf to not get the information from the
net, by deleting domain-name-server and domain-name-search from the request
part of the file.
Didn't work unfortunately.
I don't have the NetworkManager installed. The iso is based on Ubuntu 14.04.
There is probably vital information missing. I'm happy to provide it.
UPDATE:
I think I found the file that clears resolv.conf.
It seems to be /usr/share/udhcpc/default.script
#!/bin/sh
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf"
[ - n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
case "$1" in
deconfig)
/bin/ifconfig $interface 0.0.0.0
for i in /etc/ipdown.d/*; do
[ -e $i ] && . $i $interface
done
;;
renew|bound)
/bin/ifconfig $interface $ip $BROADCAST $NETMASK
if [ -n "$router" ] ; then
... (Please watch the video for the full question)
Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful
== This solution helped 28 people ==
1) You shouldn't manually update your resolv.conf, because all changes will be
overwritten by data that your local DHCP server provides. If you want it to be
static, run sudo dpkg-reconfigure resolvconf and answer "no" to dynamic
updates. If you want to add new entries there, edit /etc/resolvconf/
resolv.conf.d/base and run sudo resolvconf -u, it will append your entries and
DHCP server's entries.
2) Try to edit your /etc/network/interfaces and add your entries there, like
auto eth0
iface eth0 inet dhcp
dns-search google.com
dns-nameservers dnsserverip
and then restart /etc/init.d/networking restart or sudo ifdown -a and sudo ifup
-a
3) Your system uses [ Ссылка ] which is a very small
DHCP client program. The udhcp client negotiates a lease with the DHCP server
and notifies a set of scripts when a leases is obtained or lost. You can read
about it's usage [ Ссылка ]
openwrt/build_mips/busybox-1.1.0/networking/udhcp/README.udhcpc or just edit
this script (as you did).
With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: [ Ссылка ] | Images: [ Ссылка ] & others | With thanks to user user245423 ([ Ссылка ]), user slm ([ Ссылка ]), user Sand1512 ([ Ссылка ]), user richardkmiller ([ Ссылка ]), user Minix ([ Ссылка ]), user MAChitgarha ([ Ссылка ]), user Krishan ([ Ссылка ]), user kirill-a ([ Ссылка ]), user Ashish Jain ([ Ссылка ]), and the Stack Exchange Network ([ Ссылка ]). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.
Ещё видео!