Due to some poor behaviors in NetworkManager, I've switched over to using wicd
on my Ubuntu laptop. ( https://bugs.launchpad.net/bugs/291760 ) wicd seems to
invoke dhclient without any special action scripts, so I've quickly cobbled up
this patch to make it use dnsmasq/dbus. It should probably be smarter; e.g. it
could fallback to updating resolv.conf if the dbus-send fails. It also doesn't
do anything with IPv6 addresses. Dunno if anyone else has done this already,
so I figured I'd post it.
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/
--- dhclient-script.O 2009-03-31 16:05:29.000000000 -0700
+++ dhclient-script 2009-06-07 08:06:55.000000000 -0700
@@ -12,6 +12,14 @@
# The alias handling in here probably still sucks. -mdz
+num_addr() {
+ OIFS="$IFS"
+ IFS="."
+ set $1
+ IFS="$OIFS"
+ expr $1 \* 16777216 + $2 \* 65536 + $3 \* 256 + $4
+}
+
make_resolv_conf() {
if [ "$new_domain_name" -o "$new_domain_name_servers" ]; then
# Find out whether we are going to mount / rw
@@ -69,6 +77,20 @@
fi
}
+update_resolv() {
+ local args
+ local uaddr
+ if [ -n "$new_domain_name_servers" ]; then
+ for nameserver in $new_domain_name_servers; do
+ uaddr=`num_addr $nameserver`
+ args="$args uint32:$uaddr"
+ done
+ dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
+ /uk/org/thekelleys/dnsmasq \
+ uk.org.thekelleys.SetServers $args
+ fi
+}
+
run_hook() {
local script="$1"
local exit_status
@@ -222,7 +244,7 @@
route add -host $alias_ip_address $interface:0
fi
- make_resolv_conf
+ update_resolv
;;
@@ -266,7 +288,7 @@
route add default dev $interface gw $router $metric_arg
done
- make_resolv_conf
+ update_resolv
else
# Changed from 'ifconfig $interface inet 0 down' - see Debian bug
#144666
ifconfig $interface inet 0