[CFR] reflect resolv.conf update to running application
Matthew N. Dodd
mdodd at FreeBSD.ORG
Sat Aug 27 02:19:10 GMT 2005
On Fri, 26 Aug 2005, Brooks Davis wrote:
> On Fri, Aug 26, 2005 at 08:29:39PM -0400, Matthew N. Dodd wrote:
>> I've got modifications to dhclient-script and a Makefile in /etc/namedb/
>> that implement this behavior. I'll clean it up for public consumption if
>> others are interested.
>
> Sounds useful to me.
I've not yet come up with a good way to configure this behavior, other
than the bit that turns of the resolv.conf updating (touch
/etc/dhclient-no-resolv-conf).
/var/run/named.forwarders is updated with a Bind named.conf forwarders
configuration section containing all DHCP provided nameservers. The
Makefile is placed in /etc/namedb and /etc/namedb/named.conf is moved to
/etc/named.conf.in and modified to include the lines:
forward only;
#include "/var/run/named.forwarders"
This will cause the nameserver to never perform recursive queries directly
but to forward everything to the listed forwarders.
I'm open to suggestions on where to place the configuration knobs for this
functionality.
--
10 40 80 C0 00 FF FF FF FF C0 00 00 00 00 10 AA AA 03 00 00 00 08 00
-------------- next part --------------
Index: dhclient-script
===================================================================
RCS file: /home/cvs/src/sbin/dhclient/dhclient-script,v
retrieving revision 1.5
diff -u -u -r1.5 dhclient-script
--- dhclient-script 26 Jul 2005 18:27:37 -0000 1.5
+++ dhclient-script 12 Aug 2005 15:10:33 -0000
@@ -128,6 +128,23 @@
fi
}
+make_named_forwarders() {
+ if [ -z "$new_domain_name_servers" ]; then
+ return 1
+ fi
+
+ rm -f /var/run/named.forwarders
+ echo " forwarders {" > /var/run/named.forwarders
+ for nameserver in $new_domain_name_servers; do
+ echo " $nameserver;" >> /var/run/named.forwarders
+ done
+ echo " };" >> /var/run/named.forwarders
+
+ cd /etc/namedb && make
+
+ return 0
+}
+
add_new_resolv_conf() {
# XXX Old code did not create/update resolv.conf unless both
# $new_domain_name and $new_domain_name_servers were provided. PR
@@ -135,6 +152,10 @@
# thus broke the script. This code creates the resolv.conf if either
# are provided.
+ if [ -f /etc/dhclient-no-resolv-conf ]; then
+ return 0
+ fi
+
rm -f /etc/resolv.conf.std
if [ -n "$new_domain_name" ]; then
@@ -240,6 +261,7 @@
add_new_alias
fi
add_new_resolv_conf
+ make_named_forwarders
;;
EXPIRE|FAIL)
@@ -267,6 +289,7 @@
add_new_alias
fi
add_new_routes
+ make_named_forwarders
if add_new_resolv_conf; then
exit_with_hooks 0
fi
-------------- next part --------------
# $Id$
#
named.conf: named.conf.in /var/run/named.forwarders
cpp -P -C named.conf.in > $@
/etc/rc.d/named restart
More information about the freebsd-arch
mailing list