From be085a5185bfd25d570a7202675fe7ee82fd5b41 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 3 Mar 2022 18:00:26 +0100 Subject: vidhar: kea-dhcp4 --- hosts/vidhar/network/default.nix | 116 +++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 40 deletions(-) (limited to 'hosts') diff --git a/hosts/vidhar/network/default.nix b/hosts/vidhar/network/default.nix index e8c5ba9c..1511c4c7 100644 --- a/hosts/vidhar/network/default.nix +++ b/hosts/vidhar/network/default.nix @@ -53,49 +53,85 @@ llmnr = "false"; }; - services.dhcpd4 = { - enable = true; - interfaces = [ "lan" "mgmt" ]; - extraConfig = '' - subnet 10.141.0.0 netmask 255.255.255.0 { - range 10.141.0.128 10.141.0.254; - option domain-name-servers 10.141.0.1; - option broadcast-address 10.141.0.255; - option routers 10.141.0.1; - option domain-name "yggdrasil"; - } + services.kea = { + dhcp4 = { + enable = true; + settings = { + valid-lifetime = 4000; + rebind-timer = 2000; + renew-timer = 1000; + + interfaces-config = { + interfaces = [ "lan" "mgmt" ]; + }; - subnet 10.141.1.0 netmask 255.255.255.0 { - range 10.141.1.128 10.141.1.254; - option domain-name-servers 10.141.1.1; - option broadcast-address 10.141.1.255; - } + lease-database = { + name = "/var/lib/kea/dhcp4.leases"; + persist = true; + type = "memfile"; + }; - subnet 10.141.2.0 netmask 255.255.255.0 { - range 10.141.2.128 10.141.2.254; - option domain-name-servers 10.141.2.1; - option broadcast-address 10.141.2.255; - option routers 10.141.2.1; - } - ''; - machines = [ - { - ethernetAddress = "50:d4:f7:f3:0f:7e"; - hostName = "gauss-ap01"; - ipAddress = "10.141.0.64"; - } - { - ethernetAddress = "60:a4:b7:53:94:b5"; - hostName = "switch01"; - ipAddress = "10.141.1.2"; - } - { - ethernetAddress = "74:ac:b9:29:ad:9a"; - hostName = "ap01"; - ipAddress = "10.141.1.4"; - } - ]; + subnet4 = [ + { subnet = "10.141.0.0/24"; + option-data = [ + { name = "domain-name-servers"; + data = "10.141.0.1"; + } + { name = "broadcast-address"; + data = "10.141.0.255"; + } + { name = "routers"; + data = "10.141.0.1"; + } + { name = "domain-name"; + data = "yggdrasil"; + } + ]; + pools = [ { pool = "10.141.0.128 - 10.141.0.254"; } ]; + reservations = []; + } + { subnet = "10.141.1.0/24"; + option-data = [ + { name = "domain-name-servers"; + data = "10.141.1.1"; + } + { name = "broadcast-address"; + data = "10.141.1.255"; + } + ]; + pools = [ { pool = "10.141.1.128 - 10.141.1.254"; } ]; + reservations = [ + { hostname = "switch01"; + hw-address = "60:a4:b7:53:94:b5"; + ip-address = "10.141.1.2"; + } + ]; + } + { subnet = "10.141.2.0/24"; + option-data = [ + { name = "domain-name-servers"; + data = "10.141.2.1"; + } + { name = "broadcast-address"; + data = "10.141.2.255"; + } + { name = "routers"; + data = "10.141.2.1"; + } + ]; + pools = [ { pool = "10.141.2.128 - 10.141.2.254"; } ]; + reservations = [ + { hostname = "ap01"; + hw-address = "74:ac:b9:29:ad:9a"; + ip-address = "10.141.1.4"; + } + ]; + } + ]; + }; + }; }; + systemd.network.networks = { "eno1" = { matchConfig.Name = "eno1"; -- cgit v1.2.3