Created
August 6, 2019 01:51
-
-
Save andrewvc/fe22397c554ac3e6255681bfc864e62e to your computer and use it in GitHub Desktop.
Attempt to fix networking issues described in https://github.com/microsoft/WSL/issues/3438
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Attempt to fix broken network in WSL2.0 | |
$guest_ip = bash -c "/sbin/ifconfig eth0 | egrep -o 'inet [0-9\.]+' | cut -d ' ' -f2" | |
Write-Output "Guest IP IS: $guest_ip" | |
$gateway_ips = Get-NetIPAddress -InterfaceAlias "vEthernet (WSL)" | select IPAddress | |
$gateway_ip = $gateway_ips[1].IPAddress | |
Write-Output "Gateway (local WSL adapter) IP is: $gateway_ip" | |
bash -c "sudo ifconfig eth0 netmask 255.255.240.0" | |
bash -c "sudo ip route add default via $gateway_ip" |
RTNETLINK answers: File exists
Attempt to fix broken network in WSL2.0
$guest_ip = bash -c "ip a show eth0 | egrep -o 'inet [0-9.]+' | cut -d ' ' -f2"
Write-Output "Guest IP IS: $guest_ip"
$gateway_ips = Get-NetIPAddress -InterfaceAlias "vEthernet (WSL)" | select IPAddress
$gateway_ip = $gateway_ips[1].IPAddress
Write-Output "Gateway (local WSL adapter) IP is: $gateway_ip"
bash -c "sudo ip a add 192.168.0.1/255.255.240.0 dev eth0"
bash -c "sudo ip route add default via $gateway_ip"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
echo '(Get-NetIPAddress -InterfaceAlias "VEthernet (WSL)" | select -last 1).IPAddress' |powershell.exe -NoProfile -NoLogo | grep 192 | tr -d '\r' | read gateway; sudo ifconfig eth0 netmask 255.255.240.0; sudo ip route add default via $gateway; echo "Set gateway to $gateway"
powershell.exe: command not found