Skip to content

Instantly share code, notes, and snippets.

@xirixiz
Last active October 2, 2020 07:46
Show Gist options
  • Save xirixiz/146a56c24926707cefd41777a8b1e34a to your computer and use it in GitHub Desktop.
Save xirixiz/146a56c24926707cefd41777a8b1e34a to your computer and use it in GitHub Desktop.
WSL 2 Support for Windows 10 Versions 1903 and 1909 (DNS resolving issues)

WSL Prep #######

Enable Linux Subsystem

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Install Linux kernel update package

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

REBOOT!

I said reboot!

Get the appx release (official) of Ubuntu-20.04

https://aka.ms/wslubuntu2004

Install the appx package

Just double click on the package an follow instructions.

#######

When trying to move from WSL1 to WSL2 on Windows 10 1909 I experienced a lot of network related issues.

  • DNS not resolving locally and/or via vpn
  • Docker integration not available for WSL2 for Windows builds 1903 and 1909

First I tried to move over to WSL2 completely, but I couldn't get things fixed, so I decided to clone my WSL1 instance to a WSL2 instance instead. Only then I was able to resolve all isues follwing the below steps.

As I had to use a corporate managed Cisco AnyConnect VPN connection, I had to change priorities of the differen networking adapaters via PowerShell (Admin)

Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco"} | Set-NetIPInterface -InterfaceMetric 6000

First I had to export my Ubuntu-20.04 WSL1 instance:

wsl  --export Ubuntu-20.04  Ubuntu-20.04-default.tar

Then I created a destination location for the WSL2 instance

<somedrive>\<somedir>\Ubuntu-20.04-WSL2

Next step is to import the exported instance

wsl --import Ubuntu-20.04-WSL2 <somedrive>/<somedir>/Ubuntu-20.04-WSL2 <source_location_of_the_export>/Ubuntu-20.04-default.tar --version 2

Now lets verify...

wsl -l -v

Start the WSL2 instance.

wsl -d Ubuntu-20.04-WSL2

As the default user isn't logged in, I needed to edit /etc/wsl.conf and add the following content on the WSL2 env:

[user]
default=<your_user>

As ~/.bashrc wasn't sourced by default I had to edit ~/.bash_profile and add the following content on the WSL2 env:

if [[ -f ~/.bashrc ]] ; then
	. ~/.bashrc
fi

To apply all changes, run from the Windows PowerShell (admin)

wsl --shutdown

If you'd like to have a Windows shortcut, create one and set the following as target:

C:\Windows\System32\wsl.exe -d Ubuntu-20.04-WSL2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment