Initial attempt at reverse zones

This commit is contained in:
2023-11-01 10:13:33 -07:00
parent d3272846b4
commit 793be43cc2
2 changed files with 91 additions and 11 deletions
+30 -11
View File
@@ -8,6 +8,8 @@ let
zoneToZonefile = import ./zone-to-zonefile.nix { inherit lib; };
reverseZonefile = import ./reverse-zone.nix { inherit pkgs; };
domainOpts = { name, ... }: {
options = with types; {
domain = mkOption {
@@ -29,6 +31,13 @@ let
type = submodule zoneOpts;
description = "Definition of network zone to be served.";
};
reverse-zones = mkOption {
type = listOf str;
description =
"List of subnets for which to generate reverse lookup zones.";
default = [ ];
};
};
};
@@ -74,17 +83,27 @@ in {
identity = cfg.identity;
interfaces = cfg.listen-ips;
stateDirectory = cfg.state-directory;
zones = mapAttrs' (domain: domainCfg:
nameValuePair "${domain}." {
dnssec = domainCfg.ksk.key-file != null;
ksk.keyFile =
mkIf (domainCfg.ksk.key-file != null) domainCfg.ksk.key-file;
data = zoneToZonefile {
inherit domain;
inherit (cfg) timestamp;
inherit (domainCfg) zone;
};
}) cfg.domains;
zones = let
forwardZones = mapAttrs' (domain: domainCfg:
nameValuePair "${domain}." {
dnssec = domainCfg.ksk.key-file != null;
ksk.keyFile =
mkIf (domainCfg.ksk.key-file != null) domainCfg.ksk.key-file;
data = zoneToZonefile {
inherit domain;
inherit (cfg) timestamp;
inherit (domainCfg) zone;
};
}) cfg.domains;
reverseZones = concatMapAttrs (domain: domainOpts:
genAttrs domainOpts.reverse-zones (network:
reverseZonefile {
inherit domain network;
inherit (domainOpts.zone) nameservers;
ipHostMap = cfg.ip-host-map;
serial = cfg.timestamp;
})) cfg.domains;
in forwardZones // reverseZones;
};
};
}