aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoispha Peetz <soispha@b-peetz.de>2026-11-25 19:29:54 +0100
committerSoispha Peetz <soispha@b-peetz.de>2026-11-27 00:55:53 +0100
commitd76f348bc117a8c972ce3447591ef507293cc7f1 (patch)
treef9f2d6dab4bd023490c9e3b80192e5d84336580c
parenthosts/server2: Upgrade to nextcloud34 (diff)
downloadnixos-server-d76f348bc117a8c972ce3447591ef507293cc7f1.zip
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).
-rw-r--r--modules/by-name/co/constants/module.nix2
-rw-r--r--modules/by-name/dn/dns/module.nix27
2 files changed, 29 insertions, 0 deletions
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;
+ };
+ };
};
}