1

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.

0

I believe the MultiPathRoute option is for when you have multiple paths out of your network, such as having Internet connections from two different providers. Here, each one would have a different gateway so you can specify that traffic can be split amongst both gateways.

Doing multipath within a LAN is quite different, as all the IP addresses will be the same at either end of the links which TCP/IP over Ethernet wasn't really designed to handle. Typically it's not handled at the IP level and instead is handled at the Ethernet level, with link-aggregation (LAG) groups as you've mentioned.

Linux can configure LAG groups independently of network switches, sending packets alternately out of multiple interfaces, but this requires some planning to deal with things like packet responses arriving on a different interface to which the original message was sent on. Network switches or other machines on the network may also need additional configuration, as they will see a given machine's IP address randomly moving between two different MAC addresses. A remote PC may simply send all its traffic to the last seen MAC address, eliminating any fault tolerance or load balancing that may be in place. More complete LAG set ups will cooperate with the switch and only have one MAC address for all ports, however I have not looked into how this works where the interfaces on a PC are split across multiple switches.

I believe you'll need to look at the systemd docs for bonding to set up failover links locally as you've indicated, since you're after link aggregation rather than multipath links in and out of your LAN. If you're not after load balancing and you're happy for a link to sit idle until the primary link fails, then a lot of the issues around MAC address sharing go away - you just get a brief interruption while the fault is detected, then everything realises your IPs have changed MAC address (as they move to the backup link) then it all keeps on going.

As to the gateway info, the manpage says you can use the special value _dhcp4 or _ipv6ra to get the current gateway, however I am not sure how this works across multiple links where they all are on DHCP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.