summaryrefslogtreecommitdiff
path: root/hosts/vidhar/network/default.nix
blob: 1511c4c7bd7c5265b0b51d1dff5cba9ae1496e0d (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{ config, lib, pkgs, ... }:
{
  imports = [ ./dsl.nix ./bifrost ];

  config = {
    networking = {
      hostName = "vidhar";
      domain = "yggdrasil";
      search = [ "yggdrasil" ];

      useDHCP = false;
      useNetworkd = true;

      interfaces."lan" = {
        ipv4.addresses = [
          { address = "10.141.0.1"; prefixLength = 24; }
        ];
      };
      interfaces."mgmt" = {
        ipv4.addresses = [
          { address = "10.141.1.1"; prefixLength = 24; }
        ];
      };
      interfaces."dmz01" = {
        ipv4.addresses = [
          { address = "10.141.2.1"; prefixLength = 24; }
        ];
      };

      vlans = {
        mgmt = {
          id = 2;
          interface = "eno2";
        };
        lan = {
          id = 3;
          interface = "eno2";
        };
        dmz01 = {
          id = 4;
          interface = "eno2";
        };
      };

      firewall.enable = false;
      nftables = {
        enable = true;
        rulesetFile = ./ruleset.nft;
      };
    };

    services.resolved = {
      llmnr = "false";
    };

    services.kea = {
      dhcp4 = {
        enable = true;
        settings = {
          valid-lifetime = 4000;
          rebind-timer = 2000;
          renew-timer = 1000;

          interfaces-config = {
            interfaces = [ "lan" "mgmt" ];
          };

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

          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";
        linkConfig = {
          ActivationPolicy = "down";
        };
      };
      "eno2" = {
        matchConfig.Name = "eno2";
        networkConfig.LinkLocalAddressing = "no";
      };
    };
  };
}