configure kea

main
n0emis 3 years ago
parent 38a069e58b
commit ce23175636
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

@ -47,6 +47,10 @@ in
};
addresses = mkOption {
type = types.listOf types.str;
description = ''
Addresses to be configured on the bridge interface.
WARNING: the primary-ipv4-address to be send as a gateway address via DHCP has to be the first one.
'';
};
routingTable = mkOption {
type = types.int;
@ -73,9 +77,15 @@ in
default = "";
type = types.str;
};
searchDomains = mkOption {
default = [];
type = types.listOf types.str;
searchDomain = mkOption {
type = types.str;
};
dhcpExtraConfig = mkOption {
description = ''
Additional config that will me merged with the kea-subnet4 config
'';
default = {};
type = (pkgs.formats.json {}).type;
};
batmanAlgorithm = mkOption {
default = "batman-iv";

@ -116,6 +116,31 @@ let
RemainAfterExit = true;
};
};
#### KEA / DHCPv4 ####
keaInterfaces = if (domCfg.dhcpRange == "") then [] else [ "${mkIfName "bridge"}" ];
keaSubnet4 = mkIf (domCfg.dhcpRange != "") ([ ({
subnet = domCfg.ipv4Prefix;
pools = [
{
pool = domCfg.dhcpRange;
}
];
option-data = [
{
name = "routers";
data = head domCfg.addresses;
}
{
name = "domain-name-servers";
data = head domCfg.addresses;
}
{
name = "domain-name";
data = domCfg.searchDomain;
}
];
} // domCfg.dhcpExtraConfig) ]);
};
domConfigs = map (key: getAttr key (mapAttrs mkDomain activeDomains)) (attrNames activeDomains);
@ -128,7 +153,19 @@ in
systemd.network.netdevs = mergedConfigs.netdevs;
systemd.network.networks = mergedConfigs.networks;
systemd.network.links = mergedConfigs.links;
systemd.services = mergedConfigs.services;
ffnix.fastd.instances = mergedConfigs.fdInstances;
services.kea.dhcp4 = mkIf (concatLists mergedConfigs.keaInterfaces.contents != []) {
enable = true;
settings = {
interfaces-config = {
interfaces = mergedConfigs.keaInterfaces;
};
subnet4 = mergedConfigs.keaSubnet4;
};
};
};
}

Loading…
Cancel
Save