tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Adding openresolv to base
Hi List
I would like to propose adding openresolv [1] to the base system so that
different daemons that want to update resolv.conf(5) can do so without
stepping on each others toes. dhcpcd can handle this internally, but
only for DNS information obtained by itself.
Consider a wireless DHCP enabled interface, a static wired interface and
a PPP interface. They all compete for resolv.conf and it's normally last
one wins. Some daemons are "clever" in that they restore the last one,
but this is by no means foolproof as the interface order going up may
not be the same as going down. Also, there is a need to use name servers
from all 3 interfaces.
The obvious solution is to have a middleman which takes the resolv.conf
from each interface, merges them together to form one resolv.conf. It
should also be noified of resolv.conf removal as well. openresolv does
this, is BSD licensed and works fine in / without /usr mounted. It can
also write support files for named(8) and dnsmasq(8)(pkgsrc) to use.
openresolv is a resolvconf [2] implementation and many applications in
pkgsrc such as avahi can already take advantage of resolvconf provided
that is in /sbin.
Attached is a patch to dhclient-script which adds resolvconf support to
demonstrate how easy it is to integrate.
Comments?
Thanks
Roy
[1] http://roy.marples.name/projects/openresolv
[2] http://en.wikipedia.org/wiki/Resolvconf
Index: dhclient-script
===================================================================
RCS file: /cvsroot/src/usr.sbin/dhcp/clientscript/dhclient-script,v
retrieving revision 1.12
diff -u -p -r1.12 dhclient-script
--- dhclient-script 8 Oct 2006 17:09:32 -0000 1.12
+++ dhclient-script 24 Mar 2009 15:52:08 -0000
@@ -8,34 +8,39 @@ RESOLV=/etc/resolv.conf
SIGNATURE="# Created by dhclient from"
INTSIG="$SIGNATURE $interface"
+echo_resolv_conf() {
+ echo "$INTSIG"
+ echo search $new_domain_name
+ for nameserver in $new_domain_name_servers; do
+ echo nameserver $nameserver
+ done
+}
+
make_resolv_conf() {
if [ ! -z "$new_domain_name_servers" ]; then
- if [ -f $RESOLV ]
- then
- while read line; do
- case $line in
- "$SIGNATURE"*)
- ;;
- *)
- mv $RESOLV $RESOLV.save;;
- esac
- break
- done < $RESOLV
- fi
- echo "$INTSIG" > $RESOLV
- if [ ! -z "$new_domain_name" ]
- then
- echo search $new_domain_name >> $RESOLV
+ if [ -x /sbin/resolvconf ]; then
+ echo_resolv_conf | /sbin/resolvconf -a $interface
+ else
+ if [ -f $RESOLV ]; then
+ while read line; do
+ case $line in
+ "$SIGNATURE"*)
+ ;;
+ *)
+ mv $RESOLV $RESOLV.save;;
+ esac
+ break
+ done < $RESOLV
+ fi
+ echo_resolv_conf > $RESOLV
fi
- for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver
- done >> $RESOLV
fi
}
restore_resolv_conf() {
- if [ -f $RESOLV.save -a -f $RESOLV ]
- then
+ if [ -x /sbin/resolvconf ]; then
+ /sbin/resolvconf -d $interface
+ elif [ -f $RESOLV.save -a -f $RESOLV ]; then
while read line; do
case $line in
"$INTSIG"*)
Home |
Main Index |
Thread Index |
Old Index