Skip to content

Instantly share code, notes, and snippets.

@suiluj
Last active February 14, 2023 15:17
Show Gist options
  • Save suiluj/3d1a23c8cbce7f947e2d164b489cf81f to your computer and use it in GitHub Desktop.
Save suiluj/3d1a23c8cbce7f947e2d164b489cf81f to your computer and use it in GitHub Desktop.
WSL2 Install and configure

WSL2 Install and configure

Install distro

  • check wsl box in windows features settings
  • powershell: wsl --set-default-version 2
  • download ubuntu here: https://docs.microsoft.com/de-de/windows/wsl/install-manual
  • powershell: Add-AppxPackage .\app_name.appx (choose ubuntu.appx file)
  • powershell: wsl -l -v => wsl --setdefault <DistributionName>
  • if docker does not work just exit terminal and reenter ubuntu with "wsl"

Solve internet access dns problem

  • solve dns internet problem: microsoft/WSL#5256 (comment)
    Steps that have worked for me:
    
    Boot your distro.
    cd ~/../../etc
    Create wsl.conf, however you see fit. sudo vim wsl.conf, sudo touch wsl.conf and edit it later, whatever.
    Add these lines to wsl.conf:
    [network]
    generateResolvConf=false
    exit or in Windows cmd wsl --terminate [YourDistroName]
    Boot your distro.
    At this point, thanks to wsl.conf, run/resolvconf should no longer exist and will never be created again.
    
    cd ~/../../etc
    sudo rm resolv.conf - this deletes the existing symlink file.
    Create a new resolv.conf, however you see fit. sudo vim resolv.conf, sudo touch resolv.conf and edit it later, whatever.
    Add this line to resolv.conf:
    nameserver 8.8.8.8
    replace 8.8.8.8 with your preferred functional nameserver.
    exit or in Windows cmd wsl --terminate [YourDistroName]
    wsl --shutdown just to be sure that you've definitely killed everything.
    Boot your distro.
    Confirm that your resolv.conf changes are still in effect, or just ping a domain name and cry tears of joy after struggling to get this working for far too fucking long
    

Configure Git and Git Credential Manager Core

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