summaryrefslogtreecommitdiff
path: root/hosts/vidhar/network.nix
blob: a32dd2f8c24f3964048cb87d3131a410b9d0a5cc (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
{ config, lib, pkgs, ... }:
{
  imports = [ ./dsl.nix ];

  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; }
        ];
      };

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

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

    services.resolved = {
      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";
        }

        subnet 10.141.1.0 netmask 255.255.255.0 {
          range 10.141.1.128 10.141.1.254;
        }
      '';
      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";
        }
      ];
    };
    systemd.network.networks = {
      "eno2" = {
        matchConfig.Name = "eno2";
        networkConfig.LinkLocalAddressing = "no";
      };
    };
  };
}