- Do not save kernel source to a
/mnt/c
path, compile from the linux user home directory. Windows is case-insensitive, will cause random "file not found" compilation errors. - I'm using the Kali Windows store installation to do all these steps, this is especially important if you plan on using 8814au drivers (I don't believe they are compatible with Ubuntu)
- Windows 10, latest windows updates & WSL.
- The steps related to 8814au drivers can be modified as necessary.
- For changes to take effect, WSL requires the "6 second rule" between restarts when modifying WSL related configuration files. Meaning if you issue a
wsl --shutdown
wait 6 seconds before issuingwsl
.
sudo apt update && sudo apt upgrade
sudo apt install flex bison libssl-dev libelf-dev git dwarves bc make libncurses-dev python3
Make sure you're not inside a /mnt/c
path.
cd ~
Credit to kevin for this ingenius method, much faster than cloning github repo.
wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-$(uname -r | cut -d- -f 1).tar.gz
tar -xvf linux-msft-wsl-$(uname -r | cut -d- -f 1).tar.gz
What would we do without auto-complete..
cd WSL{TAB}
cat /proc/config.gz | gunzip > .config
make menuconfig
I opted to integrate into the kernel (*), you can also choose to compile as modules (M) this will require more setting up later (auto starting at boot)
- Networking support
- Wireless (*)
- cfg80211 (*)
- Wireless (*)
make modules -j $(expr $(nproc) - 1)
sudo make modules_install
make -j $(expr $(nproc) - 1)
Replace USERNAME with your own (duh)
mv arch/x86/boot/bzImage /mnt/c/Users/USERNAME
sudo apt install usbip usbutils iw wireshark realtek-rtl8814au-dkms
sudo nano /etc/wsl.conf
Contents:
[boot]
systemd = true
If you decided to configure cfg80211 as a module, you want to also create a autostart conf for it also
echo "8814au" | sudo tee -a /etc/modules-load.d/8814au.conf
wsl --shutdown
Replace USERNAME with your own (duh)
Contents:
# Settings apply across all Linux distros running on WSL 2
[wsl2]
# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
kernel=C:\\Users\\USERNAME\\bzImage
wsl
lsmod
Output:
Module Size Used by
8814au 2682880 0
Either on host with
usbipd wsl attach -b <BUSID>
or on VM
sudo usbip attach -r <HOSTIP/172.20.32.1> -b <BUSID>
lsusb -t
Output:
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 5000M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 480M
|__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=rtl8814au, 480M
sudo nano ~/wsl.sh
Contents:
#!/bin/sh
sudo usbip attach --remote 172.20.32.1 --busid=3-2
while true; do
if [ -z $(sudo iw dev | grep -o wlan0) ]; then
sleep 1 # network not yet up
else
break # network up
fi
done
sudo ip link set wlan0 down
sudo iw wlan0 set monitor control
sudo ip link set wlan0 up
sudo chmod +x ~/wsl.sh
sudo crontab -e
May have to select editor if first time running crontab -e
(obviously nano, unless you're a masochist).. contents:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
@reboot sh /home/ruckus/wsl.sh
Shutdown & wait for USB chime, USB chime is used as an indication it's safe to reboot.
wsl --shutdown
At this stage kernel module should auto load, USB should auto attach & wireless interface should be set in monitor mode.
wsl
Launch as sudo, otherwise you won't see network adapters
sudo wireshark