General TC > Programming & Scripting - Unofficial

how to compile wireguard kernel module for TCL

(1/5) > >>

GNUser:
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: ---$ 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

--- End code ---
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: ---$ tce-load -wi ipv6-4.19.10-tinycore
$ sudo modprobe ipv6
$ sudo depmod
$ sudo modprobe wireguard
--- End code ---
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.


GNUser:
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: ---$ tce-load -wi wireguard
--- End code ---

P.S. The extensions were submitted :)

GNUser:
I also submitted the extensions for TCL11 64-bit.

GNUser:
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: ---$ tce-load -wi wireguard-tools
$ sudo wg-quick up wg0

--- End code ---

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: ---$ sudo wg-quick up /opt/goodies/wg0.conf
--- End code ---

Rich:
Hi GNUser

--- Quote from: GNUser on June 05, 2020, 08:42:24 AM --- ... If you prefer the interface to be named tun0, simply name the config file tun0.conf. ...
--- End quote ---
Just a heads up, if you run:

--- Code: ---ifconfig -a
--- End code ---
one of the interface names returned is called  tunl0.  I don't really know what its purpose is, just wanted to point it out.

Navigation

[0] Message Index

[#] Next page

Go to full version