Bug 6788 - udhcpc / empty DNS config should not overwrite existing /etc/resolv.conf
Summary: udhcpc / empty DNS config should not overwrite existing /etc/resolv.conf
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.20.x
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-11 10:14 UTC by Andreas Heissenberger
Modified: 2014-01-13 12:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Heissenberger 2014-01-11 10:14:27 UTC
This behavior is different to the behavior of the DHCP Client under debian/ubuntu where an empty DNS entry will not delete the existing /etc/resolv.conf

example:
udhcpc -i eth0
udhcpc (v1.20.2) started
Sending discover...
Sending select for 10.0.2.15...
Lease of 10.0.2.15 obtained, lease time 86400
deleting routers
route: SIOCDELRT: No such process
adding dns 10.0.2.2

sets /etc/resolv.conf:
search me
nameserver 10.0.2.2

udhcpc -i eth1
udhcpc (v1.20.2) started
Sending discover...
Sending select for 192.168.56.105...
Lease of 192.168.56.105 obtained, lease time 1200

sets /etc/resolv.conf (empty):

I suggest to only reset /resov.conf in case of an existing nameserver entry:

/usr/share/udhcpc/default.script
@@ -28,7 +28,9 @@ case "$1" in
 			done
 		fi
 
-		echo -n > $RESOLV_CONF
+		if [ -n "$dns" ] ; then
+			echo -n > $RESOLV_CONF
+		fi
 		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
 		for i in $dns ; do
 			echo adding dns $i
--
Comment 1 Denys Vlasenko 2014-01-13 12:43:20 UTC
Fixed in git.

However, using scripts which rewrite resolv.conf
*only* based on DHCP data is bound to be problematic
in a lot of non-trivial networking setups.
You *can't* fix the script to work well for everybody.

Please read http://busybox.net/~vda/no_ifup.txt