summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/networking/services/dhcp.nix54
1 files changed, 39 insertions, 15 deletions
diff --git a/config/networking/services/dhcp.nix b/config/networking/services/dhcp.nix
index 15dce43..360eb66 100644
--- a/config/networking/services/dhcp.nix
+++ b/config/networking/services/dhcp.nix
@@ -1,21 +1,45 @@
{ config, ... }:
-let
- makeSubnet = network: ''
- subnet ${network.subnet}.0 netmask 255.255.255.0 {
- option broadcast-address ${network.subnet}.255;
- option routers ${network.machines.self.address};
- interface ${network.interface};
- range ${network.subnet}.10 ${network.subnet}.99;
- }
- '';
+let nets = config.personal.networking.networks;
in {
- services.dhcpd4 = with config.personal.networking.networks; {
+ services.kea.dhcp4 = {
enable = true;
- interfaces = [ wan.interface iot.interface ];
- extraConfig = ''
- option domain-name-servers ${lan.subnet}.1, 9.9.9.9;
- option subnet-mask 255.255.255.0;
- '' + makeSubnet wan + makeSubnet iot;
+ settings = let subnets = with nets; [ wan iot ];
+ in {
+ interfaces-config.interfaces =
+ builtins.map (network: network.interface) subnets;
+ lease-database = {
+ name = "/var/lib/kea/dhcp4.leases";
+ persist = true;
+ type = "memfile";
+ };
+ valid-lifetime = 600;
+ max-valid-lifetime = 7200;
+ option-data = [
+ {
+ name = "domain-name-servers";
+ data = "${nets.lan.subnet}.1, 9.9.9.9";
+ }
+ {
+ name = "subnet-mask";
+ data = "255.255.255.0";
+ }
+ ];
+ subnet4 = builtins.map (network: {
+ subnet = "${network.subnet}.0/24";
+ option-data = [
+ {
+ name = "broadcast-address";
+ data = "${network.subnet}.255";
+ }
+ {
+ name = "routers";
+ data = network.machines.self.address;
+ }
+ ];
+ inherit (network) interface;
+ pools = [{ pool = "${network.subnet}.10 - ${network.subnet}.99"; }];
+ }) subnets;
+ };
};
}