1

I'm trying to use systemd-networkd to configure a static route. The actual IPs are different, but here's the gist of what I'm trying to do:

ip route add 10.17.12.0/23 dev eth0

If I run this command, my networking setup works exactly as intended. I just need to establish connectivity between this host and the 10.17.12.0 subnet. My host is on a different subnet, and it cannot route there on its own for some reason. Now I want to take that same static route and configure it via a systemd-networkd file.

Here is the config I've tried using

[Match]
Name=eth0

[Route]
Gateway=10.2.100.5 # IP address of eth0 interface
Destination=10.17.12.0/23

I have also tried with Gateway set to the default gateway for the eth0 interface, but every time I get the same error:

eth0: Could not set route: Invalid argument

Any ideas what I could be doing here?

  • 1
    Did you configure a route to 10.2.100.5? The kernel needs to know how to route traffic to the gateway, in order to use it as such for another route. Though in this case I would expect the error message Could not set route: Network is unreachable. – devurandom Jul 18 '18 at 21:29
0

If you run ip route add 10.17.12.0/23 dev eth0, you'll get this in ip route show:

10.17.12.0/23 dev eth0 scope link

Note the scope link part.

So try this in your networkd configuration:

[Route]
Destination=10.17.12.0/23
Scope=link

Specifying a dummy gateway address should not be necessary then.

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.