diff options
| author | Soispha Peetz <soispha@b-peetz.de> | 2026-11-26 21:48:07 +0100 |
|---|---|---|
| committer | Soispha Peetz <soispha@b-peetz.de> | 2026-11-27 00:55:53 +0100 |
| commit | 03d15fa3744849235ea0dba976cd6582afca4499 (patch) | |
| tree | b5edd1a99dc820e1b91ae23154e2f4848a5a453a /modules/by-name/ns/nsd/module.nix | |
| parent | hosts/*: Include their deployment method in their definition (diff) | |
| download | nixos-server-03d15fa3744849235ea0dba976cd6582afca4499.zip | |
modules/dns: Separate into `nsd` and `unbound` module
They are two sides of a coin, but it makes more sense to be able to only
enable one but not the other (at least in `unbounds` case).
Diffstat (limited to '')
| -rw-r--r-- | modules/by-name/ns/nsd/module.nix (renamed from modules/by-name/dn/dns/module.nix) | 45 |
1 files changed, 7 insertions, 38 deletions
diff --git a/modules/by-name/dn/dns/module.nix b/modules/by-name/ns/nsd/module.nix index c429bba..816cc7a 100644 --- a/modules/by-name/dn/dns/module.nix +++ b/modules/by-name/ns/nsd/module.nix @@ -3,7 +3,7 @@ lib, ... }: let - cfg = config.vhack.dns; + cfg = config.vhack.nsd; localInterface = "127.0.0.1@5353"; @@ -47,8 +47,8 @@ in lib.unique (parsePorts cfg.interfaces); in { - options.vhack.dns = { - enable = lib.mkEnableOption "custom dns server"; + options.vhack.nsd = { + enable = lib.mkEnableOption "nsd, a authoritative dns server"; openFirewall = lib.mkOption { type = lib.types.bool; @@ -79,34 +79,11 @@ 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; settings = { server = { + # Otherwise, unbound will never ask the local nsd via the stub zones. do-not-query-localhost = false; - - hide-identity = true; - hide-version = true; - harden-glue = true; - harden-dnssec-stripped = true; - # 0x20-encoded randomization - use-caps-for-id = true; - - # DNSSEC - enabled by default with auto-trust-anchor-file - # auto-trust-anchor-file = "/var/lib/unbound/root.key"; }; # Forward queries for in our zones to the local nsd. @@ -119,12 +96,12 @@ in { }; }; - # 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; - interfaces = [localInterface] ++ cfg.interfaces; + interfaces = + (lib.lists.optionals config.vhack.unbound.enable [localInterface]) + ++ cfg.interfaces; inherit zones; }; @@ -140,13 +117,5 @@ in { "network-online.target" ]; }; - users = { - users = { - "unbound".uid = config.vhack.constants.ids.uids.unbound; - }; - groups = { - "unbound".gid = config.vhack.constants.ids.gids.unbound; - }; - }; }; } |
