hello, I need a bonding interface on nixos but I’m looking for a configuration example in the nixos manual, it’s not there, can you help me with bonding configuration on nixos?
thanks,
hello, I need a bonding interface on nixos but I’m looking for a configuration example in the nixos manual, it’s not there, can you help me with bonding configuration on nixos?
thanks,
systemd.network = {
enable = true;
netdevs = {
"10-bond0" = {
netdevConfig = {
Kind = "bond";
Name = "bond0";
};
bondConfig = {
Mode = "802.3ad";
TransmitHashPolicy = "layer3+4";
};
};
};
networks = {
"30-enp2s0" = {
matchConfig.Name = "enp2s0";
networkConfig.Bond = "bond0";
};
"30-enp3s0" = {
matchConfig.Name = "enp3s0";
networkConfig.Bond = "bond0";
};
"40-bond0" = {
matchConfig.Name = "bond0";
linkConfig = {
RequiredForOnline = "carrier";
};
networkConfig.LinkLocalAddressing = "no";
};
An update to this - I recently set this up and lost connectivity.
Some sources suggest using:
networking.useDHCP = lib.mkDefault true;
This alone was not enough for me and I had to explicitly add the interface:
networking.interfaces.bond0.useDHCP = lib.mkDefault true;
Hope this helps other save time and angst…
"40-bond0" = {
matchConfig.Name = "bond0";
linkConfig = {
RequiredForOnline = "routable";
};
networkConfig = {
DHCP = "ipv4";
};
};
Would probably achieve the same and stay in the networkd world.
Here’s what I ended up with. Check comments for problems this is solving.
Perhaps it’ll help somebody Could we update the NixOS manual with something like this?
networking.useNetworkd = true;
systemd.network = {
enable = true;
netdevs = {
"10-bond0" = {
netdevConfig = {
Kind = "bond";
Name = "bond0";
};
bondConfig = {
Mode = "active-backup"; # In the 802.3ad mode, I was getting huge log spam about link speed and duplex mode not being determined.
MIIMonitorSec="0.100"; # Unplugging the Ethernet cable turned full-duplex mode into half-duplex mode in /proc/net/bonding/bond0, but didn't fail over to wlan0.
PrimaryReselectPolicy="better"; # Fixes recovery after plugging in USB eth0
};
};
};
networks = {
"30-eth0" = {
matchConfig.Name = "eth0";
networkConfig.Bond = "bond0";
networkConfig.PrimarySlave = true; # without this line, unplugging and replugging the USB ethernet adapter would not reactivate the eth0 route. Curiously, unplugging/replugging the Ethernet cable itself still workde fine.
};
"30-wlan0" = {
matchConfig.Name = "wlan0";
networkConfig.Bond = "bond0";
};
"40-bond0" = {
matchConfig.Name = "bond0";
linkConfig.RequiredForOnline = "carrier";
networkConfig.DHCP = "yes";
};
};
};
MIIMonitorSec="0.100"; # Unplugging the Ethernet cable turned full-duplex mode into half-duplex mode in /proc/net/bonding/bond0, but didn't fail over to wlan0.
I needed to change “0.100” to “0.100s” or systemd-networkd did not set the miimon parameter at all (seen by looking at cat /proc/net/bonding/bond0
).