[systemd-devel] Activate netdev only on demand (e.g. for wireguard connection)

Amish anon.amish at gmail.com
Thu Mar 11 05:36:18 UTC 2021


Hello

So I have a wireguard setup which I use to connect to my server.

But I do not connect to it daily, just once a in a while.

I have setup wg0.netdev file and wg0.network file and all is working fine.

But how do I set it up such that interface wg0 does not connect 
automatically but comes up only when I run:

#networkctl up wg0

Effectively I want wireguard to connect/disconnect on demand.

Any tips or tricks?

I know I can use wg-quick at .service but I prefer to use systemd-networkd 
instead.

Currently what I do is rename .netdev to .notdev. So it does not start 
automatically. And then when I want it up. I rename it to .netdev and do:

#networkctl reload.

But thats an inefficient workaround.

I would like a solution where I can bring it up or down on demand with 
single command:

#networkctl up wg0
#networkctl down wg0

Thank you

Amish.



More information about the systemd-devel mailing list