From fe21a2d76599d39f5d09c24f317260fa00609739 Mon Sep 17 00:00:00 2001 From: Jan Vokas Date: Sat, 28 Jun 2025 12:48:16 +0200 Subject: [PATCH 1/2] refactor: dnsmasq config change After the 9.3.29 UniFi Network update, dnsmasq now handles DHCP as well as DNS, and its config files have been split into separate "dns" and "dhcp" directories. Dnsmasq is launched with `--conf-dir=/run/dnsmasq.dhcp.conf.d/` so any custom settings - even non-DHCP ones - must go into that folder. The old custom.conf no longer works. PID file location also changed. --- nspawn-container/scripts/10-setup-network.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nspawn-container/scripts/10-setup-network.sh b/nspawn-container/scripts/10-setup-network.sh index f21b50d0..0d8f9bc2 100644 --- a/nspawn-container/scripts/10-setup-network.sh +++ b/nspawn-container/scripts/10-setup-network.sh @@ -58,10 +58,10 @@ if [ -n "${IPV6_IP}" ]; then fi # Make DNSMasq listen to the container network for split horizon or conditional forwarding -if ! grep -qxF "interface=br${VLAN}.mac" /run/dnsmasq.conf.d/custom.conf; then - echo "interface=br${VLAN}.mac" >>/run/dnsmasq.conf.d/custom.conf - kill -9 "$(cat /run/dnsmasq.pid)" -fi +# Dnsmasq is now started with --conf-dir=/run/dnsmasq.dhcp.conf.d/ so we can drop +# our own config files into that directory, even if they aren't related to DHCP. +echo "interface=br${VLAN}.mac" > /run/dnsmasq.dhcp.conf.d/macvlan.conf +kill -9 "$(cat /run/dnsmasq-main.pid)" # (optional) IPv4 force DNS (TCP/UDP 53) through DNS container for intfc in ${FORCED_INTFC}; do @@ -81,4 +81,4 @@ for intfc in ${FORCED_INTFC}; do fi done fi -done \ No newline at end of file +done From f6e36013ee1eed537415901449740aabad8c0d67 Mon Sep 17 00:00:00 2001 From: Jan Vokas Date: Sat, 28 Jun 2025 13:06:32 +0200 Subject: [PATCH 2/2] condition for older unifi network versions --- nspawn-container/scripts/10-setup-network.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nspawn-container/scripts/10-setup-network.sh b/nspawn-container/scripts/10-setup-network.sh index 0d8f9bc2..01a42a8c 100644 --- a/nspawn-container/scripts/10-setup-network.sh +++ b/nspawn-container/scripts/10-setup-network.sh @@ -60,8 +60,17 @@ fi # Make DNSMasq listen to the container network for split horizon or conditional forwarding # Dnsmasq is now started with --conf-dir=/run/dnsmasq.dhcp.conf.d/ so we can drop # our own config files into that directory, even if they aren't related to DHCP. -echo "interface=br${VLAN}.mac" > /run/dnsmasq.dhcp.conf.d/macvlan.conf -kill -9 "$(cat /run/dnsmasq-main.pid)" +if [ -d /run/dnsmasq.dhcp.conf.d ]; then + # unifi network > 9.3.29 + echo "interface=br${VLAN}.mac" > /run/dnsmasq.dhcp.conf.d/macvlan.conf + kill -9 "$(cat /run/dnsmasq-main.pid)" +else + # older versions + if ! grep -qxF "interface=br${VLAN}.mac" /run/dnsmasq.conf.d/custom.conf; then + echo "interface=br${VLAN}.mac" >>/run/dnsmasq.conf.d/custom.conf + kill -9 "$(cat /run/dnsmasq.pid)" + fi +fi # (optional) IPv4 force DNS (TCP/UDP 53) through DNS container for intfc in ${FORCED_INTFC}; do