Closed Fubuchi closed 4 years ago
I have a similar issue. Strangely it worked when I first convert to WSL2, but no longer works after a reboot.
For me, the windows hosts generates a WSL ethernet card:
IP: 192.168.112.1
Mask: 255.255.240.0
For the WSL ubuntu, ifconfig
shows this:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.114.176 netmask 255.255.255.0 broadcast 192.168.114.255
inet6 fe80::215:5dff:fe2e:c311 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:2e:c3:11 txqueuelen 1000 (Ethernet)
RX packets 379 bytes 37421 (37.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13 bytes 1006 (1.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
when I try to use ping 192.168.112.1
, it comes back with connect: Network is unreachable
.
I feel the problem is with the netmask, but not sure how to deal with it given the DHCP.
i also have this issue.When i convert the Ubuntu to wsl version 1, it can connect the Internet. So i config the wsl vEthernet card,make it in the same netmask and reboot, but it doesn't work.Now i have removed the vethernet card, and i found it didn't be crearted any more...
try ifconfig down and up
I'm having this issue too. ifconfig eth0 down and up doesn't solve the problem
I think the problem is because I had another virtual machine in Hyper-V (Docker For Windows), and there was another network adapter with the name br-25ddfb4f166c and eth0 with the wrong ip. I uninstalled Docker For Windows and restarted the LxssManager (net stop LxssManager, net start LxssManager) service, and now the adapter is working normally. It may be some conflict with adapters from other virtual machines.
The problem happened again. Restarting LxssManager does not resolve.
Is it possible to inspect WSL2 virtual machine settings? Its not visible in hyper-v console.
It is not a traditional VM so no. You can see it via hcsdiag.exe and container powershell apis though.
I had just to uninstall Docker for Windows, restart and the internet started working again in WSL 2! Note that I've uninstalled all virtualization applications last week, except for Hyper-V.
I had the same issue too. network unreachable
, and nothing can connect.
The following resolved my issues:
# ifconfig eth0 netmask 255.255.240.0
# ip route add default via <WSL ethernet address>
(For me, ipconfig shows the WSL virtual eth address as 192.168.64.1.
Explanation:
I noticed that my $ ip addr
didn't quite match my \>ipconfig
:
$ ip addr show eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:db:c0:c6 brd ff:ff:ff:ff:ff:ff
inet 192.168.76.46/24 brd 192.168.76.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fedb:c0c6/64 scope link tentative
valid_lft forever preferred_lft forever
versus
ipconfig Windows IP Configuration
Ethernet adapter vEthernet (WSL):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::f513:b32c:60d5:1200%87
IPv4 Address. . . . . . . . . . . : 192.168.64.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
Virtual ethernet has subnet mask 255.255.240.0
.
So the first line changes it to the correct subnet mask.
# ifconfig eth0 netmask 255.255.240.0
For the second line, when I ran ip route, I saw:
$ ip route
192.168.64.0/20 dev eth0 proto kernel scope link src 192.168.76.46
Which basically means that only the 192.168.64.0/20 range is routable. Hence why network unreachable
for a lot of the commands.
So the second one simply adds 192.168.64.1 as the default gateway for all routes:
# ip route add default via 192.168.64.1
Where the 192.168.64.1
matches the output of the windows ipconfig
command for the WSL ipv4 address.
I don't know if this is the 100% correct approach, but it certainly fixes this issue for me.
It is not a traditional VM so no. You can see it via hcsdiag.exe and container powershell apis though.
Thanks for the info. Anecdotally, it does feel like its related to docker networking.
I seem to have found an acceptable workaround. At login, it takes a while for docker to fully initialize. With that, I added a WSL2 process that uses networking at startup which finishes before docker is initialized. Specifically I'm exporting DISPLAY and loading an X window.
Working so far.
@samscott89 ip route add default via
give me a RTNETLINK answers: File exists
. How can I make it work?
@samscott89
ip route add default via
give me aRTNETLINK answers: File exists
. How can I make it work?
You might be fine without the second step then. After applying that step, I see:
$ ip route
default via 192.168.64.1 dev eth0
192.168.64.0/20 dev eth0 proto kernel scope link src 192.168.76.46
Where 192.168.64.1
should match whatever ipconfig showed as the WSL ip address.
You will probably need (at least) both lines. If the first line is already there, then either you are good to go, or the issue is elsewhere
@samscott89 the ip address match with the ip in ipconfig but I still cannot ping or use curl. Hope MS address this issue asap because it is a blocker issue that prevent many user from trying and testing WSL 2
What's the output of ipconfig
(from cmd), and ip a
and ip route
on WSL?
ipconfig :
Ethernet adapter vEthernet (WSL):
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
Physical Address. . . . . . . . . : 00-15-5D-DB-C8-62
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::99bf:aeb5:cdf6:d3d3%47(Preferred)
IPv4 Address. . . . . . . . . . . : 172.21.176.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 788534621
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-A6-3A-23-20-47-47-77-68-96
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
ip a:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 4a:67:0b:ea:41:95 brd ff:ff:ff:ff:ff:ff
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:97:ad:4d brd ff:ff:ff:ff:ff:ff
inet 172.21.183.22/16 brd 172.21.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fe97:ad4d/64 scope link
valid_lft forever preferred_lft forever
ip route:
default via 172.21.176.1 dev eth0
172.21.0.0/16 dev eth0 proto kernel scope link src 172.21.183.22
@samscott89 the ip address match with the ip in ipconfig but I still cannot ping or use curl. Hope MS address this issue asap because it is a blocker issue that prevent many user try and test WSL 2
But yeah, fully agree. It seems I might have lucked out that my problem was actually fixable. There are a ton of related networking problems this build.
@Fubuchi The subnet mask looks wrong on yours as well. Should be 255.255.240.0 corresponding to /20
, not /16
. But I would expect it to work anyway.
There is another problem I am experiencing in WSL 2, I do not know if it has any relation to this problem but my downloads often stop.
This also happens when I install some package with apt
Good call on the subnet mask, I'll get that fixed.
Steps From @samscott89
sudo ifconfig eth0 netmask 'Subnet Mask'
5 Goto cmd and copy ' IPv4 Address'sudo ip route add default via ' IPv4 Address'
For the record, this is now fixed for me on build 18932.
I have a similar issue. Strangely it worked when I first convert to WSL2, but no longer works after a reboot.
For me, the windows hosts generates a WSL ethernet card:
IP: 192.168.112.1 Mask: 255.255.240.0
For the WSL ubuntu,
ifconfig
shows this:eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.114.176 netmask 255.255.255.0 broadcast 192.168.114.255 inet6 fe80::215:5dff:fe2e:c311 prefixlen 64 scopeid 0x20<link> ether 00:15:5d:2e:c3:11 txqueuelen 1000 (Ethernet) RX packets 379 bytes 37421 (37.4 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13 bytes 1006 (1.0 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
when I try to use
ping 192.168.112.1
, it comes back withconnect: Network is unreachable
.I feel the problem is with the netmask, but not sure how to deal with it given the DHCP.
You are right, looks like this is a dupe of https://github.com/Microsoft/WSL/issues/3438
Try this:
$ sudo ifconfig eth0 netmask 255.255.240.0
$ sudo ip route add default via 192.168.112.1
Where 192.168.112.1
and 255.255.240.0
are the IP and netmask you got on the WSL interface (run ipconfig
on windows and look for the WSL entry).
I have a similar issue. Strangely it worked when I first convert to WSL2, but no longer works after a reboot. For me, the windows hosts generates a WSL ethernet card:
IP: 192.168.112.1 Mask: 255.255.240.0
For the WSL ubuntu,
ifconfig
shows this:eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.114.176 netmask 255.255.255.0 broadcast 192.168.114.255 inet6 fe80::215:5dff:fe2e:c311 prefixlen 64 scopeid 0x20<link> ether 00:15:5d:2e:c3:11 txqueuelen 1000 (Ethernet) RX packets 379 bytes 37421 (37.4 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13 bytes 1006 (1.0 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
when I try to use
ping 192.168.112.1
, it comes back withconnect: Network is unreachable
. I feel the problem is with the netmask, but not sure how to deal with it given the DHCP.You are right, looks like this is a dupe of #3438
Try this:
$ sudo ifconfig eth0 netmask 255.255.240.0 $ sudo ip route add default via 192.168.112.1
Where
192.168.112.1
and255.255.240.0
are the IP and netmask you got on the WSL interface (runipconfig
on windows and look for the WSL entry).
this fixes the issue for me but i have to do that every time i started wsl VM.
is the real fix coming soon?
ah, i just updated to insider 18963. the issue seems to be fixed in this build.
Confirmed, it was fixed in the latest insider build.
I'm on 18963 and just ran into this issue, got it working with @samscott89's approach.
I'm on 18963 and just ran into this issue, got it working with @samscott89's approach.
i'm on 18963 and wsl2 and the issue is fixed. are you using wsl1 by any chance?
I got same issue on 18963.1000, WSL2. And @samscott89's approach works properly.
If you don't have ifconfig
command like me, use below commands:
# ip addr # check if the current address is unmatched
# ip addr del 192.168.89.250/24 dev eth0 # unmatched address of eth0
# ip addr add 192.168.80.250/20 dev eth0 # new matched address
# ip route add default via 192.168.80.1 # address of WSL2 adapter on Windows
Having the same issue on Build 18965
I think there was a regression. 18965 exhibits this issue with a WSL2 instance (openSUSE).
Having issues, 190816-1722 Ubuntu
Because there are some people have this bug in Build 18965
, I will reopen it.
I'm having the same bug, it's usually fixable issuing these on cmd:
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
However, it seems to re-appear sometimes. I hope it gets fixed soon
It's still happening on Build 18965 using Ubuntu
@faustot please try to issue the commands you see above and reboot your system
@leofabri I tried issuing the commands and rebooting, but it didn't resolve the network issue on my machine.
@faustot please try to issue the commands you see above and reboot your system
Sorry, all due respect this is not good advice: rebooting may give you the illusion of "solving" the problem because the problem itself is intermittent. Also, it does not matter if you issue or not the 4 commands you recommend before rebooting - if you are going to reboot this step is a waste of time.
If there is a mismatch between the Linux and Windows netmask, fixing the netmask and adding a default route (to the Windows IP) on the Linux guest will temporarily fix the problem - at least a reboot is not required. Unfortunately it is not a permanent fix although one can automate it using a script as demonstrated in other threads.
rebooting doesn't help anyways, running these in cmd:
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
also had no effect on wsl 2's networking either pre or post reboot
setting the netmask to match the ipconfig netmask for wsl2 doesn't help and setting
sudo ip route add default via
also to expand on this, i'm trying to apt-get update .. running a ping on a domain works fine
Seeing the same thing here on 190816-1722. The only way to "permanently" fix is to revert back to WSL1 for now.
If you're seeing this error could you help us by taking some networking logs when you're trying to access the internet?
Instructions on how to do so are here. Thanks!
feedback submitted
If you're seeing this error could you help us by taking some networking logs when you're trying to access the internet?
Instructions on how to do so are here. Thanks!
the same here in 18975 - always start with wrong ip address
I am on 10.0.18970.1005 and I had to do following 3 steps to solve this problem. 1) Set correct subnet mask sudo ifconfig eth0 netmask <Ethernet (WSL) subnet mask)> e.g: sudo ifconfig eth0 netmask 172.22.208.1 2) Set default gateway sudo ip route add default via <Ethernet (WSL) IPv4)> e.g sudo ip route add default via 172.22.208.1 3) Change DNS entry in /etc/resolv.conf with 8.8.8.8
In my case, I simply edited the /etc/resolve.conf and added my own dns entries and removed the one generated by the vm or whatever.
Typically /etc/resolv.conf is a symlink to a tmpfs location. In order for the /etc/wsl.conf setting to work, you'll also need to replace the symlink with a regular file.
My feedback too: https://aka.ms/AA627rw
Today i converted from WSL 1 to WSL 2 I didnt change from /etc/resolv.conf I tried disable firewall from Avast Premium Security and then i can update my ubuntu
But how connect to internet use firewall (Avast)?
Microsoft Windows [Version 10.0.18995.1]
Same sort of problem on 18990. Edit: problem is still there in 189950.
My subnet mask and IP route are set correctly automatically.
Ethernet adapter vEthernet (WSL):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::39ac:1623:faa1:5a4e%64
IPv4 Address. . . . . . . . . . . : 172.19.48.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
And on WSL
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.19.50.111 netmask 255.255.240.0 broadcast 172.19.63.255
inet6 fe80::215:5dff:feb4:8c78 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:b4:8c:78 txqueuelen 1000 (Ethernet)
RX packets 468 bytes 85367 (85.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 142 bytes 11761 (11.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
default via 172.19.48.1 dev eth0
172.19.48.0/20 dev eth0 proto kernel scope link src 172.19.50.111
If I try to ping outside the computer, I can't receive the packets back, but it resolves the ip address.
PING google.com (172.217.20.110) 56(84) bytes of data.
^C
--- google.com ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4167ms
Edit: No other AV or firewall is installed on the system except Windows Security
Hi guys,
I have the same problem, but I have fixed IP addresses on the interface that is connected to the internet.
So, first I remove the fixed IP addresses on the windows gui (dhcp enabled) and it worked.
Then, I put again my IP addresses and gateway.
This happen on almost all official WSL distros (suse, debian, ubuntu) . I have not tried kali yet but i think the result will be the same.
This is the report on ubuntu:
Windows build number: 10.0.18932.1000
What you're doing and what's happening:
sudo apt-get update
What's wrong / what should be happening instead:
apt-get update
again. Host name can be resolved now, but get another error:Try disable firewall, still the same error. I only use window defender, no other antivirus.
I convert my distro back to WSL 1 and every network command work fine. The content of resolv.conf in WSL 1 is surprisingly the same as when I overwrite the one in WSL 2
Expected: commands that require internet work as WSL 1
Strace of the failing command, if applicable:
can't, strace has not been installed yet beacause no internet.(I run strace on debian and got the command not found error, so I think ubuntu doesn't have them pre installed too). The log is quite long (3k+ lines) so I put them in a file: apt-strace.log