summaryrefslogtreecommitdiff
path: root/config/networking/services/dhcp.nix
diff options
context:
space:
mode:
authorquentin@aristote.fr <quentin@aristote.fr>2023-04-13 14:20:22 +0200
committerquentin@aristote.fr <quentin@aristote.fr>2023-04-13 14:20:22 +0200
commitdbb6444b03bacb9479560e8cd87ebe2776d348b3 (patch)
tree9a3bc95bfdbc63bc1695af987e7b0377b9661c37 /config/networking/services/dhcp.nix
parent25494ff6c1d9efbc04549a51186bc4fb15c63b30 (diff)
networking: restructure personal.networking modules
Diffstat (limited to 'config/networking/services/dhcp.nix')
-rw-r--r--config/networking/services/dhcp.nix35
1 files changed, 15 insertions, 20 deletions
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;
};
}