Wireguard on LXD

I am trying to get Wireguard to work inside a container.

Here is the error

Feb 18 16:02:09 wireguard systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Feb 18 16:02:09 wireguard wg-quick[9519]: [#] ip link add wg0 type wireguard
Feb 18 16:02:09 wireguard wg-quick[9519]: RTNETLINK answers: Operation not supported
Feb 18 16:02:09 wireguard wg-quick[9519]: Unable to access interface: Protocol not supported
Feb 18 16:02:09 wireguard wg-quick[9519]: [#] ip link delete dev wg0
Feb 18 16:02:09 wireguard wg-quick[9519]: Cannot find device "wg0"
Feb 18 16:02:09 wireguard systemd[1]: wg-quick@wg0.service: Main process exited, code=exited, status=1/FAILURE
Feb 18 16:02:09 wireguard systemd[1]: wg-quick@wg0.service: Failed with result 'exit-code'.
Feb 18 16:02:09 wireguard systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.

Normally this means that linux headers are not installed, but I have installed them on both the host and container as well as rebooting the host, and it made no differance.

That is the hint. This been discussed/resolved 3.0.1 wireguard iface in unprivileged container?

Thanks!

This command worked for me:

lxc launch ubuntu:18.04 wireguard -c linux.kernel_modules=wireguard

Any idea what parts need to be installed inside the container? I installed everything, but it seem like a smaller number of packages would be needed, since the host already have the kernal packages installed.

3 Likes

Only wireguard-tools should be needed in the container:

apt-get install --no-install-recommends wireguard-tools

4 Likes