From dbb6444b03bacb9479560e8cd87ebe2776d348b3 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Thu, 13 Apr 2023 14:20:22 +0200 Subject: networking: restructure personal.networking modules --- config/networking/services/dhcp.nix | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'config/networking/services/dhcp.nix') diff --git a/config/networking/services/dhcp.nix b/config/networking/services/dhcp.nix index 9953389..cca9328 100644 --- a/config/networking/services/dhcp.nix +++ b/config/networking/services/dhcp.nix @@ -1,26 +1,21 @@ { config, ... }: -let cfg = config.personal.networking; +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 + } + ''; in { - services.dhcpd4 = { + services.dhcpd4 = with config.personal.networking.networks; { enable = true; - interfaces = with cfg.interfaces; [ wlp2ghz wlp5ghz ]; - extraConfig = with cfg.subnets; '' - option domain-name-servers ${public}.1, 9.9.9.9; - subnet ${private}.0 netmask 255.255.255.0 { - option broadcast-address ${private}.255; - option routers ${private}.1; - option subnet-mask 255.255.255.0; - interface ${cfg.interfaces.wlp5ghz}; - range ${private}.10 ${private}.99; - } - subnet ${iot}.0 netmask 255.255.255.0 { - option broadcast-address ${iot}.255; - option routers ${iot}.1; - option subnet-mask 255.255.255.0; - interface ${cfg.interfaces.wlp2ghz}; - range ${iot}.10 ${iot}.99 - } - ''; + 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; }; } -- cgit v1.2.3