Skip to content

Instantly share code, notes, and snippets.

@joesturge
Created November 19, 2025 12:25
Show Gist options
  • Select an option

  • Save joesturge/6159ddf238ea8292ebc90a45ee2651b9 to your computer and use it in GitHub Desktop.

Select an option

Save joesturge/6159ddf238ea8292ebc90a45ee2651b9 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# install dependencies
sudo apt-get update
sudo apt-get install -y iproute2 iptables iputils-ping dnsutils wget
# download wsl-vpnkit and unpack
VERSION=v0.4.1
wget https://github.com/sakai135/wsl-vpnkit/releases/download/$VERSION/wsl-vpnkit.tar.gz
tar --strip-components=1 -xf wsl-vpnkit.tar.gz \
app/wsl-vpnkit \
app/wsl-gvproxy.exe \
app/wsl-vm \
app/wsl-vpnkit.service
# create directory and move unzipped files to ~/.vpn-toolkit
mkdir -p $HOME/.vpn-toolkit
mv wsl-vpnkit $HOME/.vpn-toolkit/
mv wsl-vpnkit.service $HOME/.vpn-toolkit/
mv wsl-gvproxy.exe $HOME/.vpn-toolkit/
mv wsl-vm $HOME/.vpn-toolkit/
rm wsl-vpnkit.tar.gz
# comment this line ExecStart=/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit in .service file
sed -i "s|ExecStart=/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit|#ExecStart=/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit|g" $HOME/.vpn-toolkit/wsl-vpnkit.service
# uncomment these lines in .service file
# #ExecStart=/full/path/to/wsl-vpnkit
# #Environment=VMEXEC_PATH=/full/path/to/wsl-vm GVPROXY_PATH=/full/path/to/wsl-gvproxy.exe
sed -i "s|#ExecStart=/full/path/to/wsl-vpnkit|ExecStart=/full/path/to/wsl-vpnkit|g" $HOME/.vpn-toolkit/wsl-vpnkit.service
sed -i "s|#Environment=VMEXEC_PATH=/full/path/to/wsl-vm GVPROXY_PATH=/full/path/to/wsl-gvproxy.exe|Environment=VMEXEC_PATH=/full/path/to/wsl-vm GVPROXY_PATH=/full/path/to/wsl-gvproxy.exe|g" $HOME/.vpn-toolkit/wsl-vpnkit.service
# replace all /full/path/to/ with the actual path in .service file
sed -i "s|/full/path/to/|$HOME/.vpn-toolkit/|g" $HOME/.vpn-toolkit/wsl-vpnkit.service
# create a symlink to the .service file in /etc/systemd/system
sudo ln -s $HOME/.vpn-toolkit/wsl-vpnkit.service /etc/systemd/system/wsl-vpnkit.service
# enable and start the service
sudo systemctl enable wsl-vpnkit
sudo systemctl start wsl-vpnkit
@YAMLcase
Copy link

YAMLcase commented Dec 1, 2025

Hey @joesturge, this script works perfectly. One day I'll want to uninstall it once MS get's a fix in, would you mind putting in an uninstall arg?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment