{"id":13405894,"url":"https://github.com/sakai135/wsl-vpnkit","last_synced_at":"2025-04-14T08:16:18.581Z","repository":{"id":37444071,"uuid":"297118626","full_name":"sakai135/wsl-vpnkit","owner":"sakai135","description":"Provides network connectivity to WSL 2 when blocked by VPN","archived":false,"fork":false,"pushed_at":"2024-06-03T11:50:31.000Z","size":119,"stargazers_count":2458,"open_issues_count":47,"forks_count":175,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-04-07T01:07:09.696Z","etag":null,"topics":["vpn","vpnkit","wsl","wsl2"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakai135.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-20T16:37:21.000Z","updated_at":"2025-04-06T05:09:35.000Z","dependencies_parsed_at":"2024-04-17T04:44:40.731Z","dependency_job_id":"969afb8a-644b-4795-96ba-90993f8c5e96","html_url":"https://github.com/sakai135/wsl-vpnkit","commit_stats":{"total_commits":94,"total_committers":8,"mean_commits":11.75,"dds":"0.14893617021276595","last_synced_commit":"d0444a26a96105595cdf0e7805f13231ee8f92db"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakai135%2Fwsl-vpnkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakai135%2Fwsl-vpnkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakai135%2Fwsl-vpnkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakai135%2Fwsl-vpnkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakai135","download_url":"https://codeload.github.com/sakai135/wsl-vpnkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843970,"owners_count":21170497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vpn","vpnkit","wsl","wsl2"],"created_at":"2024-07-30T19:02:15.177Z","updated_at":"2025-04-14T08:16:18.512Z","avatar_url":"https://github.com/sakai135.png","language":"Shell","funding_links":[],"categories":["Shell","WSL Tools"],"sub_categories":["10. GUI Apps"],"readme":"# wsl-vpnkit\n\nThe `wsl-vpnkit` v0.4 script uses [gvisor-tap-vsock](https://github.com/containers/gvisor-tap-vsock) to provide network connectivity to the WSL 2 VM while connected to VPNs on the Windows host. This requires no settings changes or admin privileges on the Windows host.\n\nFor previous versions, see [v0.3](https://github.com/sakai135/wsl-vpnkit/tree/v0.3.x) and [v0.2](https://github.com/sakai135/wsl-vpnkit/tree/v0.2.x).\n\n## Setup\n\nBefore setting up `wsl-vpnkit`, check if a DNS server change may be enough to get connectivity by pinging a public IP address from WSL 2. If that works, follow the steps in [WSL has no network connectivity once connected to a VPN](https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#wsl-has-no-network-connectivity-once-connected-to-a-vpn).\n\n`wsl-vpnkit` is intended to help when more than a DNS server change is needed.\n\n### Setup as a distro\n\n#### Install\n\nDownload the prebuilt file `wsl-vpnkit.tar.gz` from the [latest release](https://github.com/sakai135/wsl-vpnkit/releases/latest) and import the distro into WSL 2. \n\n```pwsh\n# PowerShell\n\nwsl --import wsl-vpnkit --version 2 $env:USERPROFILE\\wsl-vpnkit wsl-vpnkit.tar.gz\n```\n\nRun `wsl-vpnkit`. This will run `wsl-vpnkit` in the foreground.\n\n```sh\nwsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit\n```\n\n#### Update\n\nTo update, unregister the existing distro and import the new version.\n\n```pwsh\n# PowerShell\n\nwsl --unregister wsl-vpnkit\nwsl --import wsl-vpnkit --version 2 $env:USERPROFILE\\wsl-vpnkit wsl-vpnkit.tar.gz\n```\n\n#### Uninstall\n\nTo uninstall, unregister the distro.\n\n```pwsh\n# PowerShell\n\nwsl --unregister wsl-vpnkit\n```\n\n### Setup as a standalone script\n\nThe `wsl-vpnkit` script can be used as a normal script in your existing distro. This is an example setup script for Ubuntu.\n\n```sh\n# install dependencies\nsudo apt-get install iproute2 iptables iputils-ping dnsutils wget\n\n# download wsl-vpnkit and unpack\nVERSION=v0.4.x\nwget https://github.com/sakai135/wsl-vpnkit/releases/download/$VERSION/wsl-vpnkit.tar.gz\ntar --strip-components=1 -xf wsl-vpnkit.tar.gz \\\n    app/wsl-vpnkit \\\n    app/wsl-gvproxy.exe \\\n    app/wsl-vm \\\n    app/wsl-vpnkit.service\nrm wsl-vpnkit.tar.gz\n\n# run the wsl-vpnkit script in the foreground\nsudo VMEXEC_PATH=$(pwd)/wsl-vm GVPROXY_PATH=$(pwd)/wsl-gvproxy.exe ./wsl-vpnkit\n```\n\n### Setup systemd\n\nWSL versions 0.67.6 and later [support systemd](https://learn.microsoft.com/en-us/windows/wsl/wsl-config#systemd-support). Follow the instructions in the link to enable systemd support for your distro.\n\nCreate the service file and enable the service. Now `wsl-vpnkit.service` should start with your distro next time.\n\n```sh\n# wsl-vpnkit setup as a distro\nwsl.exe -d wsl-vpnkit --cd /app cat /app/wsl-vpnkit.service | sudo tee /etc/systemd/system/wsl-vpnkit.service\n\n# copy and edit for wsl-vpnkit setup as a standalone script\nsudo cp ./wsl-vpnkit.service /etc/systemd/system/\nsudo nano /etc/systemd/system/wsl-vpnkit.service\n\n# enable the service\nsudo systemctl enable wsl-vpnkit\n\n# start and check the status of the service\nsudo systemctl start wsl-vpnkit\nsystemctl status wsl-vpnkit\n```\n\n## Build\n\n\n```sh\n# build with alpine image to ./wsl-vpnkit.tar.gz\n./build.sh alpine\n\n# build with fedora using Podman\nDOCKER=podman ./build.sh fedora\n\n# import the built distro from ./wsl-vpnkit.tar.gz\n./import.sh\n\n# run using the imported distro\nwsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit\n```\n\n## Troubleshooting\n\n### Notes\n\n* Ports on the WSL 2 VM are [accessible from the Windows host using `localhost`](https://learn.microsoft.com/en-us/windows/wsl/networking#accessing-linux-networking-apps-from-windows-localhost).\n* Ports on the Windows host are accessible from WSL 2 using `host.containers.internal`, `192.168.127.254` or [the IP address of the host machine](https://docs.microsoft.com/en-us/windows/wsl/networking#accessing-windows-networking-apps-from-linux-host-ip).\n\n### Error messages from `wsl-vpnkit`\n\n#### resolv.conf has been modified without setting generateResolvConf\n\n`wsl-vpnkit` uses `/mnt/wsl/resolv.conf` to get the WSL 2 gateway IP. If modifying `/etc/resolv.conf` to set a custom DNS configuration, set [`generateResolvConf=false` in `wsl.conf`](https://learn.microsoft.com/en-us/windows/wsl/wsl-config#network-settings).\n\nOn older WSL versions where `/mnt/wsl/resolv.conf` is not available, `wsl-vpnkit` will fallback to using `/etc/resolv.conf`. When setup as a standalone script and using a custom DNS configuration for the distro, the `WSL2_GATEWAY_IP` environment variable should be set for `wsl-vpnkit` to use.\n\n#### wsl-gvproxy.exe is not executable due to WSL interop settings or Windows permissions\n\n`wsl-vpnkit` requires that the WSL 2 distro be able to run Windows executables. This [`interop` setting](https://learn.microsoft.com/en-us/windows/wsl/wsl-config#interop-settings) is enabled by default in WSL 2 and in the `wsl-vpnkit` distro.\n\nSecurity configurations on the Windows host may only permit running executables in certain directories. You can copy `wsl-gvproxy.exe` to an appropriate location and use the `GVPROXY_PATH` environment variable to specify the location.\n\n```sh\n# enable [automount] in wsl.conf for wsl-vpnkit distro\nwsl.exe -d wsl-vpnkit --cd /app sed -i -- \"s/enabled=false/enabled=true/\" /etc/wsl.conf\n\n# set GVPROXY_PATH when running wsl-vpnkit\nwsl.exe -d wsl-vpnkit --cd /app GVPROXY_PATH=/mnt/c/path/wsl-gvproxy.exe wsl-vpnkit\n```\n\n### Configuring proxies and certificates\n\n`wsl-vpnkit` currently only handles creating a network connection. Proxies and certificates must be configured separately in your distro.\n\n### Configure VS Code Remote WSL Extension\n\nIf VS Code takes a long time to open your folder in WSL, [enable the setting \"Connect Through Localhost\"](https://github.com/microsoft/vscode-docs/blob/main/remote-release-notes/v1_54.md#fix-for-wsl-2-connection-issues-when-behind-a-proxy).\n\n### Try shutting down WSL 2 VM to reset\n\n```pwsh\n# PowerShell\n\n# shutdown WSL to reset networking state\nwsl --shutdown\n\n# kill any straggler wsl-gvproxy processes\nkill -Name wsl-gvproxy\n```\n\n### Run service with debug\n\n```sh\n# set the DEBUG environment variable\nwsl.exe -d wsl-vpnkit --cd /app DEBUG=1 wsl-vpnkit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakai135%2Fwsl-vpnkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakai135%2Fwsl-vpnkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakai135%2Fwsl-vpnkit/lists"}