AllanChain / blog

Blogging in GitHub issues. Building with Astro.
https://allanchain.github.io/blog/
MIT License
13 stars 0 forks source link

WSL Cheatsheet #175

Open AllanChain opened 3 years ago

AllanChain commented 3 years ago

View Post on Blog

image

WSL issues or tricks I had to search for again and again


No Network

ping: socket: Operation not permitted
Temporary failure in name resolution

Solution 1: resolv.conf

https://github.com/microsoft/WSL/issues/6404#issuecomment-810538101

It seems lounching VSCode daemon messes things up

Setup below helped me, thanks guys:

  1. /etc/wsl.conf
[network]
generateResolvConf = false
  1. Shutdown wsl
wsl --shutdown
  1. Start wsl, delete /etc/resolv.conf symbolic link and create a file instead: /etc/resolv.conf
nameserver 8.8.8.8

But this solution ruins mDNS.

Solution 2: Check Firewall

If the DNS works after disabling Firewall, try allowing 172.16.0.0/12 inbound in Windows Defender.

Run Linux GUI apps on the Windows Subsystem for Linux

https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

Hyper-V & Reserved Ports

https://hungyi.net/posts/wsl2-reserved-ports/

Run netsh int ipv4 show excludedportrange protocol=tcp to show reserved ports.

  1. Run netsh int ipv4 set dynamic tcp start=51001 num=5000 to reset the dynamic port range.
  2. Run reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f to disable the HNS port exclusion behavior.
  3. Reboot