Systemd/networkd: Difference between revisions

imported>Mweinelt
imported>Mweinelt
Line 25: Line 25:
can write your complete network setup in native networkd configuration, you should
can write your complete network setup in native networkd configuration, you should
stay away from that option.
stay away from that option.
=== Configuring ===
The configuration of networkd happens through one or multiple configuration files per
interface stored in <code>/etc/systemd/network</code>.
The following configuration in your NixOS configuration
<syntaxhighlight lang="nix">
  systemd.network.networks."10-lan" = {
    matchConfig.Name = "lan";
    networkConfig.DHCP = "ipv4";
  };
</syntaxhighlight>
renders the following network configuration:
{{file|/etc/systemd/network/10-lan.network|ini|<nowiki>
[Match]
Name=lan
[Network]
DHCP=ipv4
</nowiki>}}
Note that we usually prefix the configuration file with a number. This can be important,
because networkd collects all available configuration files, then sorts them alphabetically,
and uses the first match for each interface as its configuration. This happens separately
for <code>.link</code>, <code>.netdev</code> and <code.network</code>, so that you
can have one configuration of each type per interface.


=== Limitations ===
=== Limitations ===