The Issue with Internet Connectivity:
I had initial issues connecting to the internet.
ping google.com
Turns out it was due to the incorrect DNS server listed in the /etc/resolv.conf. It isn't enough to edit the file since it is symlinked to /run/resolvconf/resolv.conf
.
Choose any valid DNS Server for nameserver
.
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 1.1.1.1" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf
WSL 2.0 Prerequisites
For x64 systems: Version 1903 or higher, with Build 18362 or higher.
For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.
You can determine the version via command prompt:
ver
or Powershell
[System.Environment]::OSVersion.Version
Just follow the instructions here.
Helpful Commands
Show distros installed:
wsl --list --verbose
or
wsl -l -v
Loading personal and system profiles took 941ms.
(base) PS C:\git> wsl -l -v
NAME STATE VERSION
* docker-desktop-data Running 2
Ubuntu-20.04 Running 2
Alpine Stopped 2
docker-desktop Running 2
Start a Distro
wsl -distribution <DistributionName>
or
wsl -d -t <DistributionName>
Kill/Terminate a Distro
wsl --terminate <DistributionName>
or
wsl -t <DistributionName>
Terminate All Distros
wsl --shutdown