server: switch to systemd-networkd

This commit is contained in:
chayleaf 2024-07-12 03:37:03 +07:00
parent 658732ec4e
commit 543611983c
Signed by: chayleaf
GPG key ID: 78171AD46227E68E
3 changed files with 22 additions and 6 deletions

View file

@ -35,8 +35,6 @@ in
"net.ipv4.tcp_congestion_control" = "bbr"; "net.ipv4.tcp_congestion_control" = "bbr";
}; };
networking.useDHCP = true;
/*
# as expected, systemd initrd and networking didn't work well, and i really cba to debug it # as expected, systemd initrd and networking didn't work well, and i really cba to debug it
networking.useDHCP = false; networking.useDHCP = false;
networking.useNetworkd = true; networking.useNetworkd = true;
@ -52,8 +50,18 @@ in
networks."10-dhcp" = { networks."10-dhcp" = {
DHCP = "yes"; DHCP = "yes";
name = "e*"; name = "e*";
networkConfig = {
IPv6AcceptRA = "yes";
};
dhcpV4Config = {
ClientIdentifier = "mac";
DUIDType = "link-layer";
};
dhcpV6Config = {
DUIDType = "link-layer";
};
};
}; };
};*/
boot.initrd = { boot.initrd = {
/*systemd = { /*systemd = {
@ -79,10 +87,12 @@ in
preLVMCommands = lib.mkOrder 499 '' preLVMCommands = lib.mkOrder 499 ''
ip link set end0 address ${router-config.router-settings.serverInitrdMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true ip link set end0 address ${router-config.router-settings.serverInitrdMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true
''; '';
postMountCommands = '' # postMountCommands = ''
ip link set end0 address ${router-config.router-settings.serverMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true # ip link set end0 address ${router-config.router-settings.serverMac} || ip link set eth0 address ${router-config.router-settings.serverMac} || true
''; # '';
network.enable = true; network.enable = true;
network.flushBeforeStage2 = true;
network.udhcpc.enable = true;
network.udhcpc.extraArgs = [ "-t100" ]; network.udhcpc.extraArgs = [ "-t100" ];
network.ssh = { network.ssh = {
enable = true; enable = true;

View file

@ -296,6 +296,7 @@ in {
{ ipAddress = lightBulbAddress6; { ipAddress = lightBulbAddress6;
macAddress = cfg.lightBulbMac; } macAddress = cfg.lightBulbMac; }
{ ipAddress = serverInitrdAddress6; { ipAddress = serverInitrdAddress6;
duid = cfg.serverInitrdDuid;
macAddress = cfg.serverInitrdMac; } macAddress = cfg.serverInitrdMac; }
]; ];

View file

@ -70,6 +70,11 @@
description = "server's mac address in initrd"; description = "server's mac address in initrd";
type = lib.types.str; type = lib.types.str;
}; };
serverInitrdDuid = lib.mkOption {
description = "server's duid in initrd";
type = with lib.types; nullOr str;
default = null;
};
vacuumMac = lib.mkOption { vacuumMac = lib.mkOption {
description = "robot vacuum's mac address"; description = "robot vacuum's mac address";
type = lib.types.str; type = lib.types.str;