hydra: setup bonded network

This commit is contained in:
Astro 2022-06-23 20:10:03 +02:00
parent 9372a2c902
commit 3c64d1a72c
2 changed files with 68 additions and 9 deletions

View File

@ -3,6 +3,7 @@
{
imports = [
./hardware-configuration.nix
./network.nix
./hydra.nix
./cache.nix
./updater.nix
@ -41,15 +42,6 @@
networking = {
hostName = "hydra";
firewall.enable = false;
defaultGateway = "172.20.73.1";
interfaces.enp3s0 = {
useDHCP = false;
tempAddress = "disabled";
ipv4.addresses = [{
address = "172.20.73.49";
prefixLength = zentralwerk.lib.config.site.net.serv.subnet4Len;
}];
};
nameservers = [ "172.20.73.8" "9.9.9.9" ];
};

67
hosts/hydra/network.nix Normal file
View File

@ -0,0 +1,67 @@
{ zentralwerk, config, lib, ... }:
{
networking = {
useDHCP = false;
useNetworkd = true;
};
boot.kernelParams = [
# Prevents automatic creation of interface bond0 by the kernel
"bonding.max_bonds=0"
];
systemd.network = {
enable = true;
netdevs = {
serv.netdevConfig = {
Kind = "bond";
Name = "serv";
};
# LACP
serv.bondConfig.Mode = "802.3ad";
};
networks = {
en = {
# physical ethernet ports
matchConfig.Name = "en*";
networkConfig = {
Bond = "serv";
LLDP = true;
EmitLLDP = true;
};
};
"serv" =
let
inherit (config.networking) hostName;
netConfig = zentralwerk.lib.config.site.net.serv;
address = netConfig.hosts4.${hostName};
prefixLen = netConfig.subnet4Len;
in
{
matchConfig.Name = "serv";
networkConfig = {
LLDP = true;
EmitLLDP = true;
DHCP = "no";
IPv6AcceptRA = "no";
};
addresses =
lib.optional (netConfig.hosts4 ? ${hostName}) {
addressConfig.Address = "${address}/${toString prefixLen}";
} ++
builtins.concatMap (hosts6:
lib.optional (hosts6 ? ${hostName}) {
addressConfig.Address = "${hosts6.${hostName}}/64";
}
) (builtins.attrValues netConfig.hosts6);
gateway = [
netConfig.hosts4.serv-gw
netConfig.hosts6.dn42.serv-gw
];
};
};
};
}