WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how to compile wireguard kernel module for TCL  (Read 11347 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
how to compile wireguard kernel module for TCL
« on: May 15, 2020, 12:12:54 PM »
I need wireguard for my wireless router, which is powered by TCL10 32-bit.

In case it's helpful to anyone, here's how I created the wireguard kernel module:
Code: [Select]
$ tce-load -i compiletc perl5 bash ncursesw-dev bc glibc_apps elfutils-dev git
$ cd $HOME/Downloads
$ git clone https://git.zx2c4.com/wireguard-linux-compat
$ wget http://tinycorelinux.net/10.x/x86/release/src/kernel/linux-4.19.10-patched.txz
$ wget http://tinycorelinux.net/10.x/x86/release/src/kernel/config-4.19.10-tinycore
$ tar -xvf linux-4.19.10-patched.txz
$ cd linux-4.19.10
$ cp $HOME/Downloads/config-4.19.10-tinycore .config
$ $HOME/Downloads/wireguard-linux-compat/kernel-tree-scripts/jury-rig.sh $HOME/Downloads/linux-4.19.10
$ make oldconfig
-> when asked about CONFIG_WIREGUARD choose M, when asked about CONFIG_WIREGUARD_DEBUG choose as you like (I went with y)
$ make prepare scripts
$ make M=net/wireguard modules
Now $HOME/Downloads/linux-4.19.10/net/wireguard/wireguard.ko exists and can be copied to my router as /lib/modules/4.19.10-tinycore/kernel/net/wireguard/wireguard.ko

To use it, just run depmod then load the module. Note that the ipv6 module is required. So, assuming wireguard.ko has already been copied over to the router, these are the final commands to run in the router:
Code: [Select]
$ tce-load -wi ipv6-4.19.10-tinycore
$ sudo modprobe ipv6
$ sudo depmod
$ sudo modprobe wireguard
Done! Now the wireguard kernel module is loaded and ready to go.

Note that in order to do anything useful with the module, you need wireguard-tools (wg and wg-quick), which can be found at https://www.wireguard.com/compilation and are trivial to compile.

I found out the hard way that  wg-quick  requires resolvconf or openresolv (neither of which is available in the TCL repository) and a newer version of iproute2 (for some newfangled options to the  ip  command) than what's available in the repository, but it was pretty easy to compile openresolv and iproute2.


« Last Edit: May 15, 2020, 12:17:24 PM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #1 on: May 15, 2020, 12:50:57 PM »
I'm going to submit wireguard.tcz, openresolv.tcz and updated iproute2.tcz extensions for TCL10 32bit so that other users of this TCL version don't have to redo any of the above. All they'll need to do is this:
Code: [Select]
$ tce-load -wi wireguard
P.S. The extensions were submitted :)
« Last Edit: May 15, 2020, 12:55:50 PM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #2 on: May 16, 2020, 07:39:34 AM »
I also submitted the extensions for TCL11 64-bit.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #3 on: June 05, 2020, 08:42:24 AM »
juanito: I separated wireguard.tcz into two separate extensions as you suggested (wireguard-tools.tcz and wireguard-KERNEL.tcz). I submitted the extensions for both TCL11 64-bit and TCL10 32-bit.

Fellow users: wireguard-tools.tcz is now the main extension that pulls in everything you need. So, assuming your (client) config file is /etc/wireguard/wg0.conf, this is how to create a VPN tunnel on TCL:

Code: [Select]
$ tce-load -wi wireguard-tools
$ sudo wg-quick up wg0

P.S. Interface name is based on the conf file (so wg0.conf creates an interface called wg0). If you prefer the interface to be named tun0, simply name the config file tun0.conf. Also, the config file can be in any location. If you use a location other than the default /etc/wireguard directory, you have to specify full path to the config file. For example:

Code: [Select]
$ sudo wg-quick up /opt/goodies/wg0.conf
« Last Edit: June 05, 2020, 08:48:17 AM by GNUser »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: how to compile wireguard kernel module for TCL
« Reply #4 on: June 05, 2020, 08:56:27 AM »
Hi GNUser
... If you prefer the interface to be named tun0, simply name the config file tun0.conf. ...
Just a heads up, if you run:
Code: [Select]
ifconfig -aone of the interface names returned is called  tunl0.  I don't really know what its purpose is, just wanted to point it out.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #5 on: June 05, 2020, 09:05:50 AM »
Thanks for the heads-up, Rich. I have tunl0, too, even when no vpn interface exists. I'm not sure what tunl0's purpose is, but it doesn't seem to have anything to do with vpn.

The reason I mention  tun0  is that the venerable openvpn creates tun0 by default. Because I used openvpn for a long time, all my firewall/networking scripts assume the vpn interface is named tun0. By having wireguard name its interface tun0, wireguard has been for me a drop-in replacement for openvpn :)

P.S. In my limited experience, I've found that a vpn connection created with wireguard is more stable than one created with openvpn. I used to have a script in my router that would kill openvpn and restart it every six hours, since after six hours there would sometimes be dropped connections. With wireguard, my router connected to vpn provider 10 days ago and the connection has been solid for 240 hours and counting!
« Last Edit: June 05, 2020, 09:12:39 AM by GNUser »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: how to compile wireguard kernel module for TCL
« Reply #6 on: June 05, 2020, 09:13:33 AM »
Posted - thanks for your contribution  :)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #7 on: June 05, 2020, 09:14:39 AM »
You're welcome. It's my pleasure to contribute to such a fine project :)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: how to compile wireguard kernel module for TCL
« Reply #8 on: June 05, 2020, 09:18:07 AM »
Hi GNUser
Thanks for the heads-up, Rich. I have tunl0, too, even when no vpn interface exists. I'm not sure what tunl0's purpose is, but it doesn't seem to have anything to do with vpn. ...
I mention it on the off chance someone decides to name their interface  tunl0  and it results in a conflict.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #9 on: June 05, 2020, 09:56:17 AM »
juanito - When you have time, please also post the extensions for TCL10 32-bit. My local mirror is restless until it is in sync with the official repository ;)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: how to compile wireguard kernel module for TCL
« Reply #10 on: June 05, 2020, 10:37:48 AM »
I didn't see any wireguard extensions for 32-bit?

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #11 on: June 05, 2020, 10:40:23 AM »
Hmmm. Maybe it got lost in transit. I just re-submitted it.

Offline hiro

  • Hero Member
  • *****
  • Posts: 1229
Re: how to compile wireguard kernel module for TCL
« Reply #12 on: June 05, 2020, 07:58:06 PM »
small tip after wasting some of my time with this: you really only need wg.
wg-quick doesn't support most scenarios...
the only thing you lose is the automatically added ip address and route, but that's only 2 lines of shell script ;)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to compile wireguard kernel module for TCL
« Reply #13 on: June 05, 2020, 08:15:23 PM »
Very true. wg is the main tool. wg-quick is just a simple shell script that automates the steps required for typical/basic usage.

Offline ramblurr

  • Newbie
  • *
  • Posts: 2
Re: how to compile wireguard kernel module for TCL
« Reply #14 on: October 21, 2020, 04:46:11 AM »
Any chance we could get the wireguard tczs for arm (rpi in my case)?