Wireguard onE25 running Debian or Ubuntu

Hi,

Does anybody know how to get Wireguard to work on E25 using the pre-built images of Debian or Ubuntu?

I get this error…

root@radxa-e25:/etc/systemd/system# wg-quick up /etc/wireguard/wg0.conf

[#] ip link add wg0 type wireguard
RTNETLINK answers: Operation not supported
Unable to access interface: Protocol not supported
[#] ip link delete dev wg0
Cannot find device "wg0"

Which seems to suggest the Wireguard module has not been installed.

Install the following Ubuntu packages:
wireguard - fast, modern, secure kernel VPN tunnel (metapackage)
wireguard-dkms - fast, modern, secure kernel VPN tunnel (DKMS version)
wireguard-tools - fast, modern, secure kernel VPN tunnel (userland utilities)

Hi,

Thanks for the suggestion.

I tried to install those packages but get…

Building for 4.19.193-58-rockchip-gbac1feba87f0
Building initial module for 4.19.193-58-rockchip-gbac1feba87f0
Error! Bad return status for module build on kernel: 4.19.193-58-rockchip-gbac1feba87f0 (aarch64)
Consult /var/lib/dkms/wireguard/1.0.20201112/build/make.log for more information.
dpkg: error processing package wireguard-dkms (--configure):
 installed wireguard-dkms package post-installation script subprocess returned error exit status 10
Setting up g++-9 (9.4.0-1ubuntu1~20.04.1) ...
Setting up g++ (4:9.3.0-1ubuntu2) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.8ubuntu1.1) ...
dpkg: dependency problems prevent configuration of wireguard:
 wireguard depends on wireguard-dkms (>= 0.0.20200121-2) | wireguard-modules (>= 0.0.20191219); however:
  Package wireguard-dkms is not configured yet.
  Package wireguard-modules is not installed.

dpkg: error processing package wireguard (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Errors were encountered while processing:
 wireguard-dkms
 wireguard
E: Sub-process /usr/bin/dpkg returned an error code (1)

Here is the contents of the wireguard make log…

DKMS make.log for wireguard-1.0.20201112 for kernel 4.19.193-58-rockchip-gbac1feba87f0 (aarch64)
Mon Jan 23 02:28:20 UTC 2023
make: Entering directory '/usr/src/linux-headers-4.19.193-58-rockchip-gbac1feba87f0'
  CC [M]  /var/lib/dkms/wireguard/1.0.20201112/build/main.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20201112/build/noise.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20201112/build/device.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20201112/build/peer.o
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:420:19: error: redefinition of 'ktime_get_coarse_boottime_ns'
  420 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/ktime.h:268,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:399,
                 from <command-line>:
./include/linux/timekeeping.h:134:19: note: previous definition of 'ktime_get_coarse_boottime_ns' was here
  134 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:1050:22: error: static declaration of 'ip_tunnel_parse_protocol' follows non-static declaration
 1050 | static inline __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/net/gre.h:6,
                 from ./include/linux/netfilter/nf_conntrack_proto_gre.h:5,
                 from ./include/net/netfilter/nf_conntrack.h:25,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:944,
                 from <command-line>:
./include/net/ip_tunnels.h:310:8: note: previous declaration of 'ip_tunnel_parse_protocol' was here
  310 | __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:420:19: error: redefinition of 'ktime_get_coarse_boottime_ns'
  420 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/ktime.h:268,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:399,
                 from <command-line>:
./include/linux/timekeeping.h:134:19: note: previous definition of 'ktime_get_coarse_boottime_ns' was here
  134 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:1050:22: error: static declaration of 'ip_tunnel_parse_protocol' follows non-static declaration
 1050 | static inline __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/net/gre.h:6,
                 from ./include/linux/netfilter/nf_conntrack_proto_gre.h:5,
                 from ./include/net/netfilter/nf_conntrack.h:25,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:944,
                 from <command-line>:
./include/net/ip_tunnels.h:310:8: note: previous declaration of 'ip_tunnel_parse_protocol' was here
  310 | __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:333: /var/lib/dkms/wireguard/1.0.20201112/build/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:333: /var/lib/dkms/wireguard/1.0.20201112/build/peer.o] Error 1
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:420:19: error: redefinition of 'ktime_get_coarse_boottime_ns'
  420 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/ktime.h:268,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:399,
                 from <command-line>:
./include/linux/timekeeping.h:134:19: note: previous definition of 'ktime_get_coarse_boottime_ns' was here
  134 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:1050:22: error: static declaration of 'ip_tunnel_parse_protocol' follows non-static declaration
 1050 | static inline __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/net/gre.h:6,
                 from ./include/linux/netfilter/nf_conntrack_proto_gre.h:5,
                 from ./include/net/netfilter/nf_conntrack.h:25,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:944,
                 from <command-line>:
./include/net/ip_tunnels.h:310:8: note: previous declaration of 'ip_tunnel_parse_protocol' was here
  310 | __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:333: /var/lib/dkms/wireguard/1.0.20201112/build/device.o] Error 1
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:420:19: error: redefinition of 'ktime_get_coarse_boottime_ns'
  420 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/ktime.h:268,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:399,
                 from <command-line>:
./include/linux/timekeeping.h:134:19: note: previous definition of 'ktime_get_coarse_boottime_ns' was here
  134 | static inline u64 ktime_get_coarse_boottime_ns(void)
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <command-line>:
/var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:1050:22: error: static declaration of 'ip_tunnel_parse_protocol' follows non-static declaration
 1050 | static inline __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/net/gre.h:6,
                 from ./include/linux/netfilter/nf_conntrack_proto_gre.h:5,
                 from ./include/net/netfilter/nf_conntrack.h:25,
                 from /var/lib/dkms/wireguard/1.0.20201112/build/compat/compat.h:944,
                 from <command-line>:
./include/net/ip_tunnels.h:310:8: note: previous declaration of 'ip_tunnel_parse_protocol' was here
  310 | __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:333: /var/lib/dkms/wireguard/1.0.20201112/build/noise.o] Error 1
make: *** [Makefile:1677: _module_/var/lib/dkms/wireguard/1.0.20201112/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.19.193-58-rockchip-gbac1feba87f0'

Any other suggestions

Hmmm… broken dkms package :frowning:
You’ll have to compile yourself.

First, remove the wireguard-dkms package.
sudo apt-get remove wireguard-dkms

Then, install the pre-requirements to compile:

sudo apt update
sudo apt install -y build-essential
sudo apt install -y pkg-config m4 libtool automake autoconf
sudo apt install -y ca-certificates
sudo apt install -y git

Then get the wireguard source code, apply a minor patch and make:
git clone https://git.zx2c4.com/wireguard-linux-compat
perl -pi -e “s/ktime_get_coarse_boottime_ns/_ktime_get_coarse_boottime_ns/g;” ./wireguard-linux-compat/src/compat/compat.h
make -C wireguard-linux-compat/src -j$(nproc)
sudo make -C wireguard-linux-compat/src install

Perfect thanks.

I did try compiling this before but it failed. As I was not aware of the required patch.

Thanks again

Unfortunately the stock image comes with an ancient kernel. I also had to revert the system to iptables-legacy to mark iptables work.

I have no idea if it is possible to run the native Debian kernel or a vanilla one instead. I did not even succeed in selecting another Kernel yet as I do not know which bootloader the stock-image uses.

Installing wireguard from upstream sources as suggested in this thread might work but is at least far from elegant.