Comment 2 for bug 1766527

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Sounds like this is "expected behavior". While gateway4 is available for all interfaces, it simply adds a new default route for the interface, always at a metric of 100 (if I'm not mistaken, but definitely always at the same metric value). In any case, the metric value is up to the default for networkd.

The solution around this is to set up your own default gateway via an explicit route:

route:
  - to: 0.0.0.0/0
    via: x.x.x.x
    metric: 50

Specifying the exact metric value such that it gains the right priority, if the interfaces are expected to behave with different priorities (ie. you usually want to use eth0, but if it happens to be down we'll use eth1).

For more complex scenarios, you will indeed want policy routing, which is also supported in 18.04 using netplan > 0.34 (18.04 released with netplan 0.37.1). This requires the use of "routes" along with "routing-policy". We've put an example on the netplan.io website on how to do this: https://netplan.io/examples#source-routing