about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorAndreas Rammhold <andreas@rammhold.de>2019-05-11 00:28:24 +0200
committerAndreas Rammhold <andreas@rammhold.de>2019-06-03 15:05:16 +0200
commitd600da70457a8ca8d9543eb48b73e7c5eae1656f (patch)
treee7ffd6019cce923cb978d28135ac02a8d1018750 /nixos/modules
parenta32cd7d84a7c832574ef0f09862e41bf84709baf (diff)
downloadnixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.tar
nixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.tar.gz
nixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.tar.bz2
nixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.tar.lz
nixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.tar.xz
nixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.tar.zst
nixlib-d600da70457a8ca8d9543eb48b73e7c5eae1656f.zip
nixos/networkd: use the route section for default routes
With systemd v242 using the `Gateway` attribute of the `[Network]`
section will lead to "onlink" routes on all the device that are matched
by the default configuration (typically all devices) causing multiple
default routes (even on localhost).

We can only avoid that - while keeping our default route option - when
we mark the route as explicitly not on link. Only gateways that are
within a subnet of one of the assigned interface addresses will be
installed into the routing table.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/tasks/network-interfaces-systemd.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix
index dd9ba9eec426..b9c1387cea5a 100644
--- a/nixos/modules/tasks/network-interfaces-systemd.nix
+++ b/nixos/modules/tasks/network-interfaces-systemd.nix
@@ -59,7 +59,14 @@ in
           in {
             DHCP = override (dhcpStr cfg.useDHCP);
           } // optionalAttrs (gateway != [ ]) {
-            gateway = override gateway;
+            routes = override [
+              {
+                routeConfig = {
+                  Gateway = gateway;
+                  GatewayOnlink = false;
+                };
+              }
+            ];
           } // optionalAttrs (domains != [ ]) {
             domains = override domains;
           };