blob: b380c19038365ec38c7a6e00e67a6648a30ac9d4 [file] [log] [blame]
Ari Gerusaa4b72e2024-03-20 17:14:06 +01001{ config, pkgs, lib, ... }:
2let
3 keaReservationsPreformat = lib.attrsets.mapAttrsToList (name: val: {
4 hostname = val.hostname;
5 hw-address = name;
6 ip-address = val.ip;
7 });
8in {
9 services.kea = {
10 dhcp4 = {
11 enable = true;
12 settings = {
13 interfaces-config = { interfaces = [ "lan" "bms" ]; };
14
15 lease-database = {
16 name = "/var/lib/kea/dhcp4.leases";
17 persist = true;
18 type = "memfile";
19 };
20
21 rebind-timer = 300;
22 renew-timer = 150;
23 valid-lifetime = 600;
24
25 # yanked from https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html#setting-fixed-fields-in-classification
26 # if i understand correctly, the logic is reversed to what isc-dhcp
27 # config did, but result should be the same
28 client-classes = [{
29 name = "ipxe_efi_x64";
30 test = "option[93].hex == 0x0009";
31 boot-file-name = "netboot.xyz.efi";
32 }];
33
34 subnet4 = [
35 { # general members area lan
36 subnet = "10.8.0.0/16";
37 pools = [{ pool = "10.8.0.20 - 10.8.0.199"; }];
38 reservations-out-of-pool = false;
39 reservations-in-subnet = true;
40 authoritative = true;
41
42 next-server = "10.8.1.2";
43
44 option-data = [
45 {
46 name = "routers";
47 data = "10.8.1.2";
48 }
49 {
50 name = "domain-name-servers";
51 data = "10.8.1.2";
52 }
53 {
54 name = "boot-file-name";
55 data = "netboot.xyz.kpxe";
56 }
57 ];
58
59 reservations = keaReservationsPreformat {
60 # cat old-dhcpd.conf | sed -e 's/;//g' | awk '
61 # $1 == "host" { hostname = $2; pp = "yes"; }
62 # $1 == "hardware" { hwaddr = $3; }
63 # $1 == "fixed-address" { ip = $2; }
64 # $1 == "}" && pp == "yes" {
65 # print "\"" hwaddr "\" = { ip = \"" ip "\"; hostname = \"" hostname "\"; };"
66 # pp = "no"
67 # }'
68 "00:0e:35:1d:a1:a4" = { ip = "10.8.1.18"; hostname = "laser"; };
Ari Gerusaa4b72e2024-03-20 17:14:06 +010069 "00:1b:a9:24:96:e2" = { ip = "10.8.1.21"; hostname = "brother"; };
70 "00:07:4d:4d:71:e4" = { ip = "10.8.1.22"; hostname = "zebra"; };
71 "00:30:C1:62:61:23" = { ip = "10.8.1.23"; hostname = "lj2100"; };
72 "5c:cf:7f:06:9a:3e" = { ip = "10.8.1.25"; hostname = "dht21"; };
73 "00:0A:35:00:01:22" = { ip = "10.8.1.26"; hostname = "ledpanel"; };
74 "b8:27:eb:ed:df:f9" = { ip = "10.8.1.17"; hostname = "printmaster"; };
Ari Gerusaa4b72e2024-03-20 17:14:06 +010075 "02:20:f5:20:6a:2d" = { ip = "10.8.1.30"; hostname = "3printers1cups"; };
76 "fe:77:d6:83:26:b1" = { ip = "10.8.1.31"; hostname = "telelele"; };
77 "b8:27:eb:03:69:01" = { ip = "10.8.1.32"; hostname = "vending"; };
78 "b0:38:29:2e:5d:c9" = { ip = "10.8.1.33"; hostname = "transcend"; };
79 "b8:27:eb:37:9e:6e" = { ip = "10.8.1.34"; hostname = "welcomer"; };
80 "00:23:ae:6f:8e:a7" = { ip = "10.8.1.35"; hostname = "arcade"; };
81 "90:e6:ba:84:b6:e0" = { ip = "10.8.1.38"; hostname = "inventory"; };
82 "52:54:00:1f:63:1b" = { ip = "10.8.1.39"; hostname = "camera"; };
83 # RIPE Atlas Probe
84 "c0:25:e9:99:fb:e8" = { ip = "10.8.1.43"; hostname = "ripeatlas"; };
85 "6c:ad:f8:52:4c:a7" = { ip = "10.8.1.47"; hostname = "chromecast"; };
86 # craptrap VM
87 "52:54:00:D9:DB:42" = { ip = "10.8.1.48"; hostname = "winbox"; };
88 "02:42:24:75:eb:19" = { ip = "10.8.1.49"; hostname = "staszkecoin"; };
89 "00:23:14:b0:ec:c8" = { ip = "10.8.1.51"; hostname = "blitzloop"; };
90 "00:1f:16:1c:47:df" = { ip = "10.8.1.52"; hostname = "tronxy"; };
91 "dc:a6:32:b1:68:d7" = { ip = "10.8.1.53"; hostname = "tv1"; };
92 "dc:a6:32:b1:68:83" = { ip = "10.8.1.54"; hostname = "tv2"; };
93 # kodak
Ari Gerus6a57e4f2024-04-30 17:31:03 +020094 "d8:3a:dd:f5:72:32" = { ip = "10.8.1.55"; hostname = "akamanto"; };
Ari Gerusaa4b72e2024-03-20 17:14:06 +010095 # voron
Ari Gerusd0552382024-04-02 14:22:37 +020096 "b8:27:eb:55:ad:a0" = { ip = "10.8.1.56"; hostname = "karasutengu"; };
97 # czechu's prusa mini
98 "10:9c:70:08:84:89" = { ip = "10.8.1.57"; hostname = "prusamini"; };
99 "00:17:c8:d9:2e:08" = { ip = "10.8.1.58"; hostname = "kyocera"; };
Ari Gerus6a57e4f2024-04-30 17:31:03 +0200100 # rpi3b with flashrom setup
101 "b8:27:eb:c5:64:1c" = { ip = "10.8.1.59"; hostname = "flashpi"; };
Ari Gerusaa4b72e2024-03-20 17:14:06 +0100102 };
103 }
104 { # bms
105 subnet = "10.11.1.0/24";
106 pools = [{ pool = "10.11.1.100 - 10.11.1.200"; }];
107 reservations-out-of-pool = false;
108 reservations-in-subnet = true;
109 authoritative = true;
110
111 option-data = [
112 {
113 name = "routers";
114 data = "10.11.1.1";
115 }
116 {
117 name = "domain-name-servers";
118 data = "10.11.1.1";
119 }
120 ];
121 }
122 ];
123 };
124 };
125 };
126
127 users.users.kea = {
128 group = "kea";
129 isSystemUser = true;
130 };
131 users.groups.kea = {};
132
133 systemd.services.kea-dhcp4-server.serviceConfig = {
134 UMask = lib.mkForce "0033";
135 DynamicUser = lib.mkForce false;
136 };
137}