nixos/network-interfaces-systemd: do not ignore /0 gateway routes

While it might seem odd, 0.0.0.0/0 or ::/0 gateways are valid and
commonly used on point-to-point links (e.g. a wireguard tunnel) to
indicate that all traffic needs to be sent to a given interface.

systemd-networkd actually documents this as a valid configuration in its
man pages [1].

Tested to do the right thing in one of my NixOS containers using
a Wireguard tunnel as its default route.

[1] https://www.freedesktop.org/software/systemd/man/systemd.network.html#DefaultRouteOnDevice=
This commit is contained in:
Pierre Bourdon 2022-08-19 02:22:47 +02:00
parent 5efa052928
commit 4ae5da5394
No known key found for this signature in database
GPG key ID: 6FB80DCD84DA0F1C

View file

@ -134,7 +134,7 @@ in
# Most of these route options have not been tested.
# Please fix or report any mistakes you may find.
routeConfig =
optionalAttrs (route.prefixLength > 0) {
optionalAttrs (route.address != null && route.prefixLength != null) {
Destination = "${route.address}/${toString route.prefixLength}";
} //
optionalAttrs (route.options ? fastopen_no_cookie) {