Package: dnsmasq
Version: 2.76-4
Severity: normal
Tags: patch
I use a dnsmasq.conf setting that registers netmasq on 127.0.1.1 (still
interface lo).
With the unmodified initscript, this results in the name resolution
failing because
dnsmasq only listens on 127.0.1.1 which the init script tells
resolvconf to query 127.0.0.1,
which doesn't have a listening resolver on most of my machines.
Attached is a patch that teaches the init script to read the relevant
setting from
dnsmasq.conf and passing the correct value to resolvconf, falling back
to 127.0.0.1
if the setting wasn't found or didn't match the right pattern.
-- System Information:
Debian Release: stretch/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 4.6.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
--- dnsmasq.init.orig 2016-11-08 22:27:33.352332003 -0500
+++ dnsmasq.init 2016-11-08 22:27:50.548723969 -0500
@@ -132,8 +133,22 @@
[ $interface = lo ] && return
done
- if [ -x /sbin/resolvconf ] ; then
- echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.$NAME
+ if [ -x /sbin/resolvconf ] ; then
+ # Use the first valid listen-address but not 0.0.0.0
+ # dnsmasq.conf has one line per listen-address, not a list in
+ # one line.
+ IP=$(awk 'match( \
+ $0, \
+ /^listen-address=([0-9.]*)[^0-9.]*$/, arr \
+ ) { print arr[1] }' < /etc/dnsmasq.conf \
+ | grep -vE '^0\.0\.0\.0' \
+ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' \
+ | head -n 1
+ )
+ if [[ -z "${IP}" ]]; then
+ IP=127.0.0.1
+ fi
+ echo "nameserver ${IP}" | /sbin/resolvconf -a lo.$NAME
fi
return 0
}