You are not logged in.

#1 2019-10-09 11:42:24

connexion2000
Member
Registered: 2006-10-15
Posts: 116

systemd equivalent of command: ip -4 route add 10.0.0.0/8 dev wg0

Hi,
I am trying to setup wireguard using systemd. wireguard-tools performed series of commands like:

ip -4 route add 10.0.0.0/8 dev wg0-dev

.
I would like to recreate it using systemd, for now I have this unit file:

[Match]
Name = wg0

[Network]
Address = x.x.x.x
DNS = x.x.x.x, x.x.x.x
DefaultRouteOnDevice=true

[Route]
Destination = 10.0.0.0/8
GatewayOnlink=true
Scope = link

However it doesn't produce desired results as ip -r doesn't show this route. How can I specify route with device instead of gateway?

Offline

#2 2019-10-09 13:37:11

Swiggles
Member
Registered: 2014-08-02
Posts: 259

Re: systemd equivalent of command: ip -4 route add 10.0.0.0/8 dev wg0

[Match]
Name=wg0

[Network]
Address=10.0.0.123/8
DNS=x.x.x.x, x.x.x.x
DefaultRouteOnDevice=true

Should already do the trick. See https://www.freedesktop.org/software/sy … twork.html

Last edited by Swiggles (2019-10-10 19:12:56)

Offline

#3 2019-10-09 13:59:17

connexion2000
Member
Registered: 2006-10-15
Posts: 116

Re: systemd equivalent of command: ip -4 route add 10.0.0.0/8 dev wg0

Thanks for response.

Unfortunately it adds default route through wg0, ip r gives:

default dev wg0 proto static

I would like to have only some routes on wg0, something like:

10.0.0.0/8 dev wg0 scope link 

Last edited by connexion2000 (2019-10-10 12:12:29)

Offline

#4 2019-10-09 16:17:30

Swiggles
Member
Registered: 2014-08-02
Posts: 259

Re: systemd equivalent of command: ip -4 route add 10.0.0.0/8 dev wg0

/etc/systemd/network/wg0.network

[Match]
Name=wg0

[Address]
Address=10.0.0.123/8

/etc/systemd/network/eno1.network

[Match]
Name=eno1

[Network]
Address=192.168.130.123/24
Gateway=192.168.130.1

Like this?

Last edited by Swiggles (2019-10-09 17:08:08)

Offline

#5 2019-10-10 12:12:00

connexion2000
Member
Registered: 2006-10-15
Posts: 116

Re: systemd equivalent of command: ip -4 route add 10.0.0.0/8 dev wg0

Sorry, wrong line pasted, I meant:

10.0.0.0/8 dev wg0-dev scope link 

so "via" part is omitted.

Offline

#6 2019-10-10 19:17:08

Swiggles
Member
Registered: 2014-08-02
Posts: 259

Re: systemd equivalent of command: ip -4 route add 10.0.0.0/8 dev wg0

What I noticed just now is that the syntax is specified without spaces in the docs of systemd. Maybe that's the problem here? Now we did a full turn I was thinking your original post is already the likely solution unless it is ommited, because there should already be an implicit route.
Could you please show the current config, output of "ip route" and see if there are any journal entries?

Offline

Board footer

Powered by FluxBB