Bug 6788

Summary: udhcpc / empty DNS config should not overwrite existing /etc/resolv.conf
Product: Busybox Reporter: Andreas Heissenberger <andreas>
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.20.x   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:

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