summaryrefslogtreecommitdiff
path: root/os/srv/kea.nix
blob: 168590e2baa48bd5429dccde06b287e222dabb5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ config, lib, ... }:
let
  cfg = config.os.srv.kea;
in
{
  options.os.srv.kea.enable = lib.mkEnableOption "enables kea dhcp server";
  config = lib.mkIf cfg.enable {
    services.kea.dhcp4 = {
      enable = true;
      settings = {
        interfaces-config = {
          # To be used in a VM
          interfaces = [ "eth0" ];
          dhcp-socket-type = "udp";
        };

        lease-database = {
          type = "memfile";
          persist = true;
          name = "/var/lib/kea/dhcp4.leases";
        };

        subnet4 = [
          {
            id = 1;
            subnet = "10.1.0.0/24";
            pools = [ { pool = "10.1.0.50 - 10.1.0.250"; } ];
            option-data = [
              {
                name = "routers";
                data = "10.1.0.1";
              }
              {
                name = "domain-name-servers";
                data = "10.0.0.3";
              }
            ];
          }
          {
            id = 2;
            subnet = "10.2.0.0/24";
            pools = [ { pool = "10.2.0.50 - 10.2.0.250"; } ];
            option-data = [
              {
                name = "routers";
                data = "10.2.0.1";
              }
              {
                name = "domain-name-servers";
                data = "10.0.0.3";
              }
            ];
          }
        ];
      };
    };
  };
}