summaryrefslogtreecommitdiffstats
path: root/configs/networkd.nix
diff options
context:
space:
mode:
Diffstat (limited to 'configs/networkd.nix')
-rw-r--r--configs/networkd.nix28
1 files changed, 22 insertions, 6 deletions
diff --git a/configs/networkd.nix b/configs/networkd.nix
index d9f93a0f..180991ba 100644
--- a/configs/networkd.nix
+++ b/configs/networkd.nix
@@ -5,15 +5,31 @@
networking.useNetworkd = true;
networking.useDHCP = false;
- # Don't use DNS servers received from DHCP servers. The networks are
- # called 40-NAME like the ones from
+ # The networks are called 40-NAME like the ones from
# <nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix>, so the
- # settings merge into them.
- systemd.network.networks =
- mylib.genAttrs'
+ # settings merge into them: systemd uses only the first file that matches
+ # an interface, so with 00-NAME it would stay degraded (configured), and
+ # 99-NAME would be ignored.
+ systemd.network.networks = lib.mkMerge [
+
+ # Don't use DNS servers received from DHCP servers.
+ (mylib.genAttrs'
(builtins.attrNames config.networking.interfaces)
(name: lib.nameValuePair "40-${name}" {
dhcpV4Config.UseDNS = lib.mkDefault false;
dhcpV6Config.UseDNS = lib.mkDefault false;
- });
+ }))
+
+ # Prefer ethernet: its DHCP routes get metric 512 instead of 1024.
+ (mylib.genAttrs'
+ (builtins.filter
+ (name:
+ config.hrm.network.interfaces.${name}.medium == "ethernet" &&
+ config.networking.interfaces ? ${name})
+ (builtins.attrNames config.hrm.network.interfaces))
+ (name: lib.nameValuePair "40-${name}" {
+ inherit name;
+ dhcpV4Config.RouteMetric = 512;
+ }))
+ ];
}