From 64f1104dea3cfbcd78d9485af61fb7412d7403e1 Mon Sep 17 00:00:00 2001 From: Clara Engler Date: Thu, 9 Jul 2026 15:17:56 +0200 Subject: [PATCH] nixos/unbound: resolveLocalQueries with resolved This adds support for services.unbound.resolveLocalQueries with systemd-resolved by improving the general behavior similar to the dnsmasq module. With this change, it not only adjusts resolvconf (which is not used when systemd-resolved is used) but also prepends the loopback addresses to networking.nameservers. --- nixos/modules/services/networking/unbound.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/unbound.nix b/nixos/modules/services/networking/unbound.nix index af8664fd3137..5bafebcf10f4 100644 --- a/nixos/modules/services/networking/unbound.nix +++ b/nixos/modules/services/networking/unbound.nix @@ -115,7 +115,7 @@ in default = true; description = '' Whether unbound should resolve local queries (i.e. add 127.0.0.1 to - /etc/resolv.conf). + /etc/resolv.conf and set name servers to localhost respectively). ''; }; @@ -276,6 +276,7 @@ in resolvconf = { useLocalResolver = mkDefault true; }; + nameservers = lib.mkBefore ([ "127.0.0.1" ] ++ (optional config.networking.enableIPv6 "::1")); }; environment.etc."unbound/unbound.conf".source = confFile;