Bonding Interface

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";
      };
2 Likes

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 = "carrier";
        };
        networkConfig = {
          DHCP = "ipv4";
        };
      };

Would probably achieve the same and stay in the networkd world.

1 Like