You are not logged in.

#1 2020-01-12 23:13:05

Maniaxx
Member
Registered: 2014-05-14
Posts: 732

[SOLVED] systemd-networkd - remove interface on stop

Hallo,
i've set up a wireguard connection with systemd-networkd as described here. Everything works properly so far but when i stop the service (systemctl stop systemd-networkd) the adapter wg0 is still up and running and 'sudo wg' also shows a proper wireguard tunnel up.

How can i remove/stop the interface when systemd-networkd service goes down?

Last edited by Maniaxx (2020-01-14 16:47:54)


sys2064

Offline

#2 2020-01-14 03:07:34

chr0mag
Member
From: Vancouver, Canada
Registered: 2017-02-02
Posts: 94

Re: [SOLVED] systemd-networkd - remove interface on stop

Maniaxx wrote:

Hallo,
i've set up a wireguard connection with systemd-networkd as described here. Everything works properly so far but when i stop the service (systemctl stop systemd-networkd) the adapter wg0 is still up and running and 'sudo wg' also shows a proper wireguard tunnel up.

This is intentional. man systemd-networkd says the following:

When systemd-networkd exits, it generally leaves existing network devices and configuration intact. This makes it possible to transition from the initramfs
and to restart the service without breaking connectivity. This also means that when configuration is updated and systemd-networkd is restarted, netdev
interfaces for which configuration was removed will not be dropped, and may need to be cleaned up manually.

Maniaxx wrote:

How can i remove/stop the interface when systemd-networkd service goes down?

Maybe try adding something like the snippet below as a systemd-networkd drop-in file?

ExecStopPost=/usr/bin/ip link set down wg0
ExecStopPost=/usr/bin/ip link del dev wg0

Offline

#3 2020-01-14 16:47:36

Maniaxx
Member
Registered: 2014-05-14
Posts: 732

Re: [SOLVED] systemd-networkd - remove interface on stop

So that behavior is indeed intended. I'll go for manually deleting the device as described then.

Thanks!


sys2064

Offline

Board footer

Powered by FluxBB