wg-quick: Add flag `WG_QUICK_PREFER_USERSPACE_IMPLEMENTATION`
"Nicolai S" <[email protected]> Fri, 09 Jan 2026 14:41:31 +0000
| Newsgroups | com.zx2c4.lists.wireguard |
|---|---|
| Message-ID | <[email protected]> |
While developing a userspace implementation of wireguard, or if users hav=
e
special requirements for which implementation of wg to use, etc, it would=
be
nice to be able to force `wg-quick` to use `WG_QUICK_USERSPACE_IMPLEMENTA=
TION`.
But currently, if your kernel supports wireguard, then `wg-quick` will ig=
nore
the `WG_QUICK_USERSPACE_IMPLEMENTATION` environment variable (on linux).
This patch introduces `WG_QUICK_PREFER_USERSPACE_IMPLEMENTATION` to get `=
wg-quick`
to use the userspace implementation.
Note that `darwin.bash` already prefers `WG_QUICK_USERSPACE_IMPLEMENTATIO=
N` if set.
If we instead want the darwin behavior in `linux.bash` then I suggest mer=
ging
this patch: https://lists.zx2c4.com/pipermail/wireguard/2025-March/008773=
.html
Signed-off-by: Nicolai S=C3=B8borg <wg @ xn--sb-lka.org>
---
src/wg-quick/linux.bash | 5 ++++-
1 file changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash
index 34fa5f9..be867d5 100755
--- a/src/wg-quick/linux.bash
+++ b/src/wg-quick/linux.bash
@@ -88,7 +88,10 @@ auto_su() {
=20
=20add_if() {
local ret
- if ! cmd ip link add dev "$INTERFACE" type wireguard; then
+ if [[ -n "$WG_QUICK_PREFER_USERSPACE_IMPLEMENTATION" ]]; then
+ echo "[!] Forcing userspace implementation." >&2
+ cmd "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" "$INTERFACE"
+ elif ! cmd ip link add dev "$INTERFACE" type wireguard; then
ret=3D$?
[[ -e /sys/module/wireguard ]] || ! command -v "${WG_QUICK_USERSPACE_I=
MPLEMENTATION:-wireguard-go}" >/dev/null && exit $ret
echo "[!] Missing WireGuard kernel module. Falling back to slow usersp=
ace implementation." >&2