WSL Troubleshooting
Related Resources
- [WSL2] Checkpoint VPN breaks network connectivity
- Networking issues while using VPN
- No network connection in any distribution under WSL 2
Introduction
This document is written in our company in order to solve the issues with WSL2, CheckPoint VPN and other self-hosted services. You're welcome to suggest more fixes in this subject to make this document more general.
Network and DNS Troubleshooting
Try each command by their order to better find the correct problem.
ping 8.8.8.8
Try If it failed it means that you don’t have an internet connection at all.
See this video and/or [WSL2] Checkpoint VPN breaks network connectivity (comment) to solve this issue.
Probably the base thing is to connect to the VPN before WSL2 Network Adapter.
- Open your WSL Terminal.
- Disconnect from the VPN (if connected)
- Disable the WSL2 Network Adapter by
netsh interface set interface "vEthernet (WSL)" disable
or byGet-NetAdapter -Name "vEthernet (WSL)" | Disable-NetAdapter
- Please make sure it disabled by
$(Get-NetAdapter -Name "vEthernet (WSL)").Status
isDisabled
- Connect to the VPN
- Enable the WSL2 Network Adapter by
netsh interface set interface "vEthernet (WSL)" enable
orGet-NetAdapter -Name "vEthernet (WSL)" | Enable-NetAdapter
- Validate the ping 8.8.8.8 in WSL again.
ping google.com
Try If it failed it means that you have a problem with the DNS. You need to update the /etc/resolve.conf
with your DNS addresses.
Run this command in PowerShell: Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object -ExpandPropert ServerAddresses
, then take the addresses from that command, clear the resolve.conf
file and set the first line search {your domain}
and then the next line will be nameserver {ip}
.
Source: you can use this script (from Networking issues while using VPN (comment)) to auto-update the resolve.conf
.
ping {internalIP}
Try If it failed it means that you have a problem with the VPN.
ping {internal hostname}
Try If it failed it means that you have a problem with the internal DNS.
Make sure you configured the DNS by the instructions in 2.
Other connection issues
Clone a git repo by SSH
If you’re trying to clone a private repo, you need your credentials that usually configured in the Windows system.
My suggestion is to use SSH, here is an instruction to configure the SSH keys in TFS:
- Create an SSH key in WSL with
ssh-keygen -C your.name@company.com
, and paste the~/.ssh/id_rsa.pub
in{tfs-host}/tfs/_details/security/keys
-
If you are getting an error with
diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
(I don’t remember the original error), create/edit the~/.ssh/config
file with:Host tfs2018app KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
- Get the SSH repository URL.
- Clone.
You can try to use the Windows Git Credential Manager with/instead of using SSH, and share the consequences in this document.
npm network timeout
If you are getting the next error when you are trying to use npm
, please share the solution with us:
npm ERR! network timeout at: https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.10.4.tgz
You can try this:
- run
Get-NetIPInterface
on windows to findMTU
value for VPN network adapter (mine was 1350) - run
sudo ifconfig eth0 mtu 1350
orsudo ip link set dev eth0 mtu 1350
inside WSL to match eth0MTU
value with vpn network adapter value