I recently set up a server with its network managed directly by systemd-networkd (nuked netplan.io and Network Manager) and gave it static IPs like this:
/etc/systemd/network/10-ethernet.network
[Match]
Name=eno1
[Network]
Address=192.168.1.2/24
Gateway=192.168.1.1
DNS=192.168.1.1
After restarting systemd-networkd.service, default routes look like this:
default via 192.168.1.1 dev eno1 proto static
default via 172.16.0.1 dev eno2 proto static
default via 172.31.255.1 dev eno3 proto static
^^^
Because there are multiple NICs and I want to make eno1 the preferred one, I want the routes laid out like this:
default via 192.168.1.1 dev eno1 proto static metric 100
default via 172.16.0.1 dev eno2 proto static metric 300
default via 172.31.255.1 dev eno3 proto static metric 500
^^^^^^^^^^
Without the metric value, it default to 0, meaning all routes have the same priority (highest), which I want to avoid.
I've tried this setting:
[Route]
Gateway=192.168.1.1
Metric=100
But it only generates an extra route with the desired metric while the original ones (missing metric) still remaining.
I'm running on Systemd 240. How should I achieve this?