radicle: update
[julm/julm-nix.git] / hosts / aubergine / networking / ethernet.nix
index 68045c35b219d1bddf6cf526cf31725cf9143207..c6cf99e132c28fdc94541ce3678c567fd4af5410 100644 (file)
@@ -2,18 +2,59 @@
 with (import ./names-and-numbers.nix);
 with (import ./names-and-numbers.nix.clear);
 {
-  networking.interfaces = {
-    ${eth1Iface} = {
-      useDHCP = false;
-      ipv4.addresses = [{ address = "${eth1IPv4}.1"; prefixLength = 24; }];
+  systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
+  systemd.network.enable = true;
+  systemd.network.wait-online = {
+    enable = false;
+  };
+  systemd.network.networks = {
+    "10-${eth1Iface}" = {
+      name = eth1Iface;
+      networkConfig = {
+        Address = "${eth1IPv4}.1/24";
+        DHCPServer = true;
+      };
+      dhcpServerConfig = {
+        DNS = "${eth1IPv4}.1";
+        EmitDNS = true;
+        PoolOffset = 100;
+        PoolSize = 20;
+      };
+      linkConfig = {
+        RequiredForOnline = "no";
+      };
     };
-    ${eth2Iface} = {
-      useDHCP = false;
-      ipv4.addresses = [{ address = "${eth2IPv4}.1"; prefixLength = 24; }];
+    "10-${eth2Iface}" = {
+      name = eth2Iface;
+      networkConfig = {
+        Address = "${eth2IPv4}.1/24";
+        DHCPServer = true;
+      };
+      dhcpServerConfig = {
+        DNS = "${eth2IPv4}.1";
+        EmitDNS = true;
+        PoolOffset = 100;
+        PoolSize = 20;
+      };
+      linkConfig = {
+        RequiredForOnline = "no";
+      };
     };
-    ${eth3Iface} = {
-      useDHCP = false;
-      ipv4.addresses = [{ address = "${eth3IPv4}.1"; prefixLength = 24; }];
+    "10-${eth3Iface}" = {
+      name = eth3Iface;
+      networkConfig = {
+        Address = "${eth3IPv4}.1/24";
+        DHCPServer = true;
+      };
+      dhcpServerConfig = {
+        DNS = "${eth3IPv4}.1";
+        EmitDNS = true;
+        PoolOffset = 100;
+        PoolSize = 20;
+      };
+      linkConfig = {
+        RequiredForOnline = "no";
+      };
     };
   };
   networking.networkmanager = {
@@ -23,6 +64,7 @@ with (import ./names-and-numbers.nix.clear);
       eth3Iface
     ];
   };
+
   networking.nftables.ruleset = lib.mkAfter ''
     table inet filter {
       chain input {
@@ -35,66 +77,8 @@ with (import ./names-and-numbers.nix.clear);
       }
       chain forward-to-lan { }
       chain forward {
-        iifname { "enp2s0", "enp3s0", "enp4s0", "wlp5s0" } oifname  { "enp2s0", "enp3s0", "enp4s0", "wlp5s0" } goto forward-to-lan
+        iifname { ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname  { ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } goto forward-to-lan
       }
     }
   '';
-
-  systemd.services.dhcpd4.onFailure = [
-    "network-addresses-${eth1Iface}.service"
-    "network-addresses-${eth2Iface}.service"
-    "network-addresses-${eth3Iface}.service"
-  ];
-  services.dhcpd4 = {
-    enable = true;
-    interfaces = [
-      eth1Iface
-      eth2Iface
-      eth3Iface
-    ];
-    extraConfig = ''
-      subnet ${eth1IPv4}.0 netmask 255.255.255.0 {
-        range ${eth1IPv4}.100 ${eth1IPv4}.200;
-        option broadcast-address ${eth1IPv4}.255;
-        option domain-name-servers ${eth1IPv4}.1;
-        option routers ${eth1IPv4}.1;
-        option subnet-mask 255.255.255.0;
-        group {
-          host patate1 {
-            hardware ethernet ${patateMAC};
-            fixed-address ${eth1IPv4}.3;
-          }
-        }
-      }
-
-      subnet ${eth2IPv4}.0 netmask 255.255.255.0 {
-        range ${eth2IPv4}.100 ${eth2IPv4}.200;
-        option broadcast-address ${eth2IPv4}.255;
-        option domain-name-servers ${eth2IPv4}.1;
-        option routers ${eth2IPv4}.1;
-        option subnet-mask 255.255.255.0;
-        group {
-          host patate2 {
-            hardware ethernet ${patateMAC};
-            fixed-address ${eth2IPv4}.3;
-          }
-        }
-      }
-
-      subnet ${eth3IPv4}.0 netmask 255.255.255.0 {
-        range ${eth3IPv4}.100 ${eth3IPv4}.200;
-        option broadcast-address ${eth3IPv4}.255;
-        option domain-name-servers ${eth3IPv4}.1;
-        option routers ${eth3IPv4}.1;
-        option subnet-mask 255.255.255.0;
-        group {
-          host patate3 {
-            hardware ethernet ${patateMAC};
-            fixed-address ${eth3IPv4}.3;
-          }
-        }
-      }
-    '';
-  };
-
 }