I have a NAS host with two LAG interfaces. Each LAG goes to a different switch in the same subnet. I'd like to setup multipath routing such that connections to the local subnet (and beyond) are free to select either interface and have the kernel adjust the weights if it sees the carrier go down due to a switch failure. I'd also like to use
systemd-networkd to manage the configuration.
The desired end state using
iproute2 looks like:
$ ip route add default nexthop via 10.0.0.1 dev lag0 nexthop via 10.0.0.1 dev lag1 $ ip route add 10.0.0.0/16 nexthop dev lag0 nexthop dev lag1 $ ip route default nexthop via 10.0.0.1 dev lag1 weight 1 nexthop via 10.0.0.1 dev lag0 weight 1 10.0.0.0/16 nexthop dev lag0 weight 1 nexthop dev lag1 weight 1
To do this via
systemd-networkd, I probably need to use the somewhat-recently added
MultiPathRoute= property. However it's a bit unclear how. The syntax requires a gateway, which I would not have in the case of the local subnet. Even in the case of the default route,
systemd-networkd does not setup a multi-path route the same way
iproute2 does, it just sets up two routes. If I omit the
MultiPathRoute= directive from the local subnet route (but not the default route),
systemd-networkd does not complain about any invalid units on restart.
# /etc/systemd/network/lag0.network [Match] #... [Network] #... [Route] Destination=10.0.0.0/16 Scope=link MultiPathRoute=???????@lag0 [Route] Destination=0.0.0.0/0 Scope=global MultiPathRoute=10.0.0.1@lag0 # /etc/systemd/network/lag1.network [Match] #... [Network] #... [Route] Destination=10.0.0.0/16 Scope=link MultiPathRoute=???????@lag1 [Route] Destination=0.0.0.0/0 Scope=global MultiPathRoute=10.0.0.1@lag1
A somewhat unrelated question is how to get the route and default gateway information when using DHCP on these interfaces, but that might be pushing my luck too far.