diff options
Diffstat (limited to 'modules/by-name')
| -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; }; |
