Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd-networkd peer syntax #92

Merged
merged 1 commit into from
Mar 29, 2022
Merged

Conversation

mbonino
Copy link
Contributor

@mbonino mbonino commented Mar 21, 2022

Systemd-networkd managed wireguard interfaces use [WireGuardPeer] rather than [Peer].

Friendly names need a peer section in config file. This change allow using both wireguard config files and systemd-networkd config files.

Systemd-networkd config file uses ``[WireGuardPeer]`` rather than ``[Peer]``.
@MindFlavor
Copy link
Owner

Great! thank you!

@MindFlavor MindFlavor merged commit 86cc251 into MindFlavor:master Mar 29, 2022
@aa-matthias
Copy link

Hi @mbonino - short question - where are you setting the friendly names in this use case? are they part of the netplan?

@mbonino
Copy link
Contributor Author

mbonino commented Apr 12, 2022

Hi @aa-matthias,

I don't use netplan, I use systemd-networkd to create Wireguard interfaces.

On my Ubuntu 20.04 server, I have create file /etc/systemd/network/20-wg0.netdev

File content:

[NetDev]
Name = wg0
Kind = wireguard
Description = WireGuard tunnel

[WireGuard]
ListenPort = 51860
PrivateKey = <privatekey>

[WireGuardPeer]
# friendly_name = admin
PublicKey = <blabla>
AllowedIPs = 192.168.1.2/32
AllowedIPs = 192.168.1.3/32
AllowedIPs = 192.168.1.4/32
AllowedIPs = 192.168.1.5/32

@aa-matthias
Copy link

aa-matthias commented Apr 12, 2022

Thanks for the heads up!

I thought of using netplan and systemd-networkd as a renderer to have only one place for all network config but I assume it's not possible to create the # friendly_name = .... property in this case

https://netplan.io/reference/#properties-for-device-type-tunnels%3A

@mbonino
Copy link
Contributor Author

mbonino commented Apr 12, 2022

I guess support for friendly_name has to be added upstream.
Currently netplan's parser for Wireguard doesn't support friendly names as far as I can tell.

https://github.com/canonical/netplan/blob/a73859781619331c466f38386009c7b9146366b2/src/networkd.c#L167

@bastelfreak
Copy link
Contributor

Hi people,
why not use the description attribute that systemd-networkd already supports?

@mbonino
Copy link
Contributor Author

mbonino commented Sep 30, 2022

Hi @bastelfreak,

systemd-networkd support the description attribute at [NetDev] level. This means one attribute per interface.
A wireguard interface can have multiple peers, so we can't use it. Each peer needs its own attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants