Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created August 6, 2019 01:51
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewvc/fe22397c554ac3e6255681bfc864e62e to your computer and use it in GitHub Desktop.
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
# 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"
@ArrowRaider
Copy link

RTNETLINK answers: File exists

@mnadeem
Copy link

mnadeem commented Aug 8, 2021

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