With a minor modification, the suggested patch seems to work correctly for me
on both IPv4 and IPv6 static configurations.
The modification I have added is to clear the variables DNS, DNS6, DOMAINS,
DOMAINS6, DEFAULT_ROUTE before importing the state files,
otherwise their previous contents may be carried through. Without this, I was
getting a search domain of "DOMAINS" configured in resolved.
I have attached a source patch against ifupdown master on Salsa.
I note that the resolved hook script we're working with here seems to be
derived from the (fairly hacky) dhclient hook scripts being shipped by Ubuntu.
To get DNS working for DHCP cases as well as for static ones, will require a
corresponding hook script for dhclient in Debian: see bug #1025062.
Note also in ifupdown it is possible to have independent DHCP and/or static
configurations for IPv4 and IPv6 on the same interface.
I'm not sure how common those cases are, but the hook scripts for ifupdown and
dhclient would have to use the same protocol and state file for it to work with
all the possible combinations. I'm going to post a comment and patch against
bug #1025062 to this effect.
-Ken.
diff --git a/debian/if-up.d/resolved b/debian/if-up.d/resolved
index cb331ca..e79f997 100755
--- a/debian/if-up.d/resolved
+++ b/debian/if-up.d/resolved
@@ -43,11 +43,11 @@ if systemctl is-enabled systemd-resolved > /dev/null 2>&1; then
fi
if [ -n "$NEW_DNS" ]; then
cat <<EOF >"$mystatedir/ifupdown-${ADDRFAM}-$interface"
-"$DNS"="$NEW_DNS"
+$DNS="$NEW_DNS"
EOF
if [ -n "$NEW_DOMAINS" ]; then
cat <<EOF >>"$mystatedir/ifupdown-${ADDRFAM}-$interface"
-"$DOMAINS"="$NEW_DOMAINS"
+$DOMAINS="$NEW_DOMAINS"
EOF
fi
fi
@@ -66,7 +66,7 @@ EOF
# ignore errors due to nonexistent file
md5sum "$mystatedir/isc-dhcp-v4-$interface" "$mystatedir/isc-dhcp-v6-$interface" "$mystatedir/ifupdown-inet-$interface" "$mystatedir/ifupdown-inet6-$interface" > "$newstate" 2> /dev/null || true
if ! cmp --silent "$oldstate" "$newstate" 2>/dev/null; then
- DNS DNS6 DOMAINS DOMAINS6 DEFAULT_ROUTE
+ unset DNS DNS6 DOMAINS DOMAINS6 DEFAULT_ROUTE
# v4 first
if [ -e "$mystatedir/isc-dhcp-v4-$interface" ]; then
. "$mystatedir/isc-dhcp-v4-$interface"