Skip to content

Instantly share code, notes, and snippets.

@saade
Created February 6, 2022 21:42
Show Gist options
  • Save saade/d0810d7d25193c37d600cc74ef06aa1d to your computer and use it in GitHub Desktop.
Save saade/d0810d7d25193c37d600cc74ef06aa1d to your computer and use it in GitHub Desktop.
Fix WSL ethernet connection.
=============================================================================
FIX WSL2 NETWORKING IN WINDOWS 10
=============================================================================
cmd as admin:
wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
Windows Search > Network Reset
Restart Windows
-----------------------------------------------------------------------------
# Fix network issues
# Delete auto-generated files
[root@PC-NAME user]# rm /etc/resolv.conf || true
[root@PC-NAME user]# rm /etc/wsl.conf || true
# Enable changing /etc/resolv.conf
# Enable extended attributes on Windows drives
[root@PC-NAME user]# cat <<EOF > /etc/wsl.conf
[network]
generateResolvConf = false
[automount]
enabled = true
options = "metadata"
mountFsTab = false
EOF
# Use google nameservers for DNS resolution
[root@PC-NAME user]# cat <<EOF > /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
Exit Linux WSL
cmd as admin:
wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
Windows Search > Network Reset
Restart Windows
https://github.com/microsoft/WSL/issues/5336
New-NetFirewallRule -DisplayName "WSL allow in" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment