diff options
| author | Soispha Peetz <soispha@b-peetz.de> | 2026-11-26 01:14:46 +0100 |
|---|---|---|
| committer | Soispha Peetz <soispha@b-peetz.de> | 2026-11-27 00:55:53 +0100 |
| commit | 9ae289bf774e52f2ff2c81b5138afc2138ec7b6b (patch) | |
| tree | 36caaffec1b21f60285d4b452bb5c0ed80669066 /modules/by-name/dn | |
| parent | hosts: Use correct path to the `host.toml` file for the deploy hosts (diff) | |
| download | nixos-server-9ae289bf774e52f2ff2c81b5138afc2138ec7b6b.zip | |
modules/dns: Use the local nsd server to serve access to our zones
Diffstat (limited to '')
| -rw-r--r-- | modules/by-name/dn/dns/module.nix | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/modules/by-name/dn/dns/module.nix b/modules/by-name/dn/dns/module.nix index cbd8d03..c429bba 100644 --- a/modules/by-name/dn/dns/module.nix +++ b/modules/by-name/dn/dns/module.nix @@ -5,6 +5,8 @@ }: let cfg = config.vhack.dns; + localInterface = "127.0.0.1@5353"; + zones = builtins.mapAttrs (name: value: { data = @@ -12,6 +14,20 @@ }) cfg.zones; + stubZones = + lib.mapAttrsToList (name: value: { + name = "${name}"; + stub-addr = localInterface; + + # Don't use published NS records, always use stub-addr + stub-prime = false; + + # Don't cache the stub responses, it is literally on the same host. + stub-no-cache = true; + }) + cfg.zones; + zoneNames = builtins.attrNames cfg.zones; + dns = import ./dns {inherit lib;}; ports = let @@ -78,6 +94,29 @@ in { enable = true; stateDir = "/var/lib/unbound"; resolveLocalQueries = true; + settings = { + server = { + 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. + # It makes resolves little bit faster for the real deployment, + # and importantly breaks the dependency on another ns server. + stub-zone = stubZones; + + # Our local zones do not have DNSSEC, so we need to mark them as insecure. + domain-insecure = zoneNames; + }; }; # Use nsd to serve our own zone files, with the configured NS record pointing to the @@ -85,7 +124,7 @@ in { services.nsd = { enable = true; verbosity = 4; - inherit (cfg) interfaces; + interfaces = [localInterface] ++ cfg.interfaces; inherit zones; }; |
