Systemd/networkd: Difference between revisions
imported>Mweinelt  Created page with "Networkd is the network configuration component of the systemd software suite. It is well integrated into NixOS below <code>systemd.network<code> and should be preferred over..."  | 
				imported>Mweinelt mNo edit summary  | 
				||
| Line 1: | Line 1: | ||
Networkd is the network configuration component of the systemd software suite. It is well integrated into NixOS below <code>systemd.network<code> and should be preferred over <code>networking.interfaces</code> options for most use cases, since it receives far superior maintenance.  | Networkd is the network configuration component of the systemd software suite. It is well integrated into NixOS below <code>systemd.network</code> and should be preferred over <code>networking.interfaces</code> options for most use cases, since it receives far superior maintenance.  | ||
Configuration for networkd is split into three sections.  | Configuration for networkd is split into three sections.  | ||
Revision as of 16:03, 26 March 2023
Networkd is the network configuration component of the systemd software suite. It is well integrated into NixOS below systemd.network and should be preferred over networking.interfaces options for most use cases, since it receives far superior maintenance.
Configuration for networkd is split into three sections.
systemd.network.linksreconfigures existing network devices- https://www.freedesktop.org/software/systemd/man/systemd.link.html
 - actually implemented by udev, not networkd
 
systemd.network.netdevscreates virtual network devicessystemd.network.networksconfigures network devices
In most simple scenarios configuring existing network devices is what you want to do.
Enabling
To be able to use networkd configuration it needs to be enabled first.
systemd.network.enable = true;
Some guides will mention the networking.useNetworkd option, which
offers translation of some networking.* options into networkd. If you
can write your complete network setup in native networkd configuration, you should
stay away from that option.
Examples
Examples should be concise and give proper hints on how to achieve a working network-online.target.
Bonding
Given two hardlinks enp2s0 and enp3s0 create a virtual bond0 interface using Dynamic LACP (802.3ad), hashing outgoing packets using a packet's Layer3/4 (OSI Layer) information.
  systemd.network = {
    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";
      };
  };