From d76f348bc117a8c972ce3447591ef507293cc7f1 Mon Sep 17 00:00:00 2001 From: Soispha Peetz Date: Wed, 25 Nov 2026 19:29:54 +0100 Subject: modules/dns: Also use a resolving dns server nsd only does the authoritative dns hosting (think a web server), but unbound does the actual dns querying, with DNSSEC resolving and everything. Before that we implicitly had kresd, as that was what the snm had enabled, but unbound and nsd are meant to work together (both from NLNet). --- modules/by-name/co/constants/module.nix | 2 ++ modules/by-name/dn/dns/module.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'modules') diff --git a/modules/by-name/co/constants/module.nix b/modules/by-name/co/constants/module.nix index 51bf68b..4ddb689 100644 --- a/modules/by-name/co/constants/module.nix +++ b/modules/by-name/co/constants/module.nix @@ -72,6 +72,7 @@ lpadmin = 358; msr = 359; polkituser = 360; + unbound = 361; # As per the NixOS file, the uids should not be greater or equal to 400; }; @@ -127,6 +128,7 @@ systemd-coredump # matches systemd-coredump user systemd-oom wpa_supplicant + unbound ; # The gid should match the uid. Thus should not be >= 400; diff --git a/modules/by-name/dn/dns/module.nix b/modules/by-name/dn/dns/module.nix index 8f4ad37..cbd8d03 100644 --- a/modules/by-name/dn/dns/module.nix +++ b/modules/by-name/dn/dns/module.nix @@ -63,6 +63,25 @@ in { }; config = lib.mkIf cfg.enable { + vhack.persist.directories = [ + { + directory = "/var/lib/unbound"; + user = "unbound"; + group = "unbound"; + mode = "0700"; + } + ]; + + # Use unbound for resolving all local DNS queries. + # unbounds also has the upside to verify DNSSEC. + services.unbound = { + enable = true; + stateDir = "/var/lib/unbound"; + resolveLocalQueries = true; + }; + + # Use nsd to serve our own zone files, with the configured NS record pointing to the + # servers ip address. services.nsd = { enable = true; verbosity = 4; @@ -82,5 +101,13 @@ in { "network-online.target" ]; }; + users = { + users = { + "unbound".uid = config.vhack.constants.ids.uids.unbound; + }; + groups = { + "unbound".gid = config.vhack.constants.ids.gids.unbound; + }; + }; }; } -- cgit v1.3.1