Re: dhclient-script and resolv.conf

Previous thread: small drm uvm diff by Ted Unangst on Tuesday, December 14, 2010 - 10:05 pm. (2 messages)

Next thread: Fw: cwm: xev_reconfig -> xu_reconfig by Thomas Pfaff on Wednesday, December 15, 2010 - 10:33 am. (2 messages)
From: Claudio Jeker
Date: Wednesday, December 15, 2010 - 8:08 am

This made me go nuts for a long time. As soon as you have two interfaces
running dhclient those two will start fighting over /etc/resolv.conf
which is realy bad when short lease times are used and one interface is
not getting new leases.

This diff extends the dhclient-script in such a way that dhclient will
only restore the "old" resolv.conf file if it actually is in charge of the
current file. With this the fighting does not stop but is less
noticable.


Index: dhclient-script
===================================================================
RCS file: /cvs/src/sbin/dhclient/dhclient-script,v
retrieving revision 1.17
diff -u -p -r1.17 dhclient-script
--- dhclient-script	2 Jun 2010 09:57:16 -0000	1.17
+++ dhclient-script	4 Nov 2010 11:18:59 -0000
@@ -111,21 +111,21 @@ add_new_resolv_conf() {
 	# $new_domain_name are provided. As reported in PR#3135, some ISPs
 	# provide only $new_domain_name_servers.
 
-	rm -f /etc/resolv.conf.std
+	rm -f /etc/resolv.conf.$interface.std
 
 	if [ -n "$new_domain_name" ]; then
-		echo "search $new_domain_name" >>/etc/resolv.conf.std
+		echo "search $new_domain_name" >>/etc/resolv.conf.$interface.std
 	fi
 
 	if [ -n "$new_domain_name_servers" ]; then
 		for nameserver in $new_domain_name_servers; do
-			echo "nameserver $nameserver" >>/etc/resolv.conf.std
+			echo "nameserver $nameserver" >>/etc/resolv.conf.$interface.std
 		done
 	fi
 
-	if [ -f /etc/resolv.conf.std ]; then
+	if [ -f /etc/resolv.conf.$interface.std ]; then
 		if [ -f /etc/resolv.conf.tail ]; then
-			cat /etc/resolv.conf.tail >>/etc/resolv.conf.std
+			cat /etc/resolv.conf.tail >>/etc/resolv.conf.$interface.std
 		fi
 
 		# In case (e.g. during OpenBSD installs) /etc/resolv.conf
@@ -133,10 +133,9 @@ add_new_resolv_conf() {
 		# the new data in the correct location.
 
 		if [ -f /etc/resolv.conf ]; then
-			cat /etc/resolv.conf > /etc/resolv.conf.save
+			cat /etc/resolv.conf > /etc/resolv.conf.$interface.save
 		fi
-		cat /etc/resolv.conf.std > ...
From: Martin Pelikan
Date: Friday, December 17, 2010 - 4:50 am

Have you considered using something like openresolv in the base
system? I'll be probably reworking my RDNSS implementation in rtsold
and rtadvd because of the new RFC 6106, which is already in "standards
track". Of course it adds another fighter over resolv.conf...
-- 
Martin Pelikan

From: Kenneth R Westerback
Date: Friday, December 17, 2010 - 5:48 am

This looks like a step forward, and worth trying out. ok krw@.

.... Ken

From: frantisek holop
Date: Sunday, December 26, 2010 - 1:15 pm

also, do you know of a good way to modify the order of the interfaces?
(besides the alphabet ;-)

-f
-- 
if you can't see black, white has no meaning

Previous thread: small drm uvm diff by Ted Unangst on Tuesday, December 14, 2010 - 10:05 pm. (2 messages)

Next thread: Fw: cwm: xev_reconfig -> xu_reconfig by Thomas Pfaff on Wednesday, December 15, 2010 - 10:33 am. (2 messages)