Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl2 no internet access (unable to resolve host address) on windows 1909 build 18363.1139 #6427

Open
armenic opened this issue Jan 13, 2021 · 109 comments
Labels

Comments

@armenic
Copy link

armenic commented Jan 13, 2021

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.1139]
Your Distribution version: Ubuntu 18.04 LTS
Whether the issue is on WSL 2 and/or WSL 1: Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020

Steps to reproduce

sudo apt update

WSL logs:

Expected behavior

connect to linux archives and fetch the updates

Actual behavior

manukyae@GNELTCG8424MZX:~$ sudo apt update
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
manukyae@GNELTCG8424MZX:~$
@armenic
Copy link
Author

armenic commented Jan 13, 2021

About 90K of my company employees are on this version of the windows and we do not have any means to upgrade windows ourselves. I assume similar thing happens in other companies.
The biggest frustration was to find out that WSL2 does not work after waiting for this for a year. And now I have to wait another year and hopefully with the next enterprise incremental update wsl2 starts working. I hope Microsoft can push a hotfix.

@craigloewen-msft
Copy link
Member

What is your networking set up like on this machine? Do you have any VPNs?

@armenic
Copy link
Author

armenic commented Jan 13, 2021

hi @craigloewen-msft, thank you so much the follow-up. We do have an option to use VPN and most of the time it is turned off. I can get any extra information you need if you tell me how to get that information :)
By the way, your demo videos of wsl-2 are super cool and will attract a lot of developers to use WSL-2, so please make it working https://docs.microsoft.com/en-us/windows/wsl/about

@armenic
Copy link
Author

armenic commented Jan 13, 2021

by the way if I convert the distro to use WSL-1 wsl --set-version Ubuntu-18.04 1 it works like a charm and I really, really want that WSL-2 also works like it.

@craigloewen-msft
Copy link
Member

Could you please try the scenario where you don't have internet access and try to use WSL 2 both with the VPN turned on and off?

And could you also file feedback when you're in the state where your network access doesn't work? (Instructions here).

Also thank you for the positive feedback! 😁

@armenic
Copy link
Author

armenic commented Jan 13, 2021

I did the following:

  1. reset the Ubuntu 18.04 LTS app
  2. connect VPN
  3. start Ubuntu app
  4. problem with sudo apt update persists
  5. disconnect VPN
  6. problem with sudo apt update persists
  7. repeat step 1 and 3
  8. problem with sudo apt update persists

Unfortunately I am not able to file data since my organization settings prevent Feedback Hub to work as you see below. Sorry for that.
image
image

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 14, 2021

@armenic: Can you please the output of the following commands:

  • ip a
  • ip route show
  • traceroute 1.1.1.1
  • cat /etc/resolv.conf

?

@armenic
Copy link
Author

armenic commented Jan 14, 2021

@OneBlue, thanks for follow-up:

manukyae@GNELTCG8424MZX:~$ 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 16:e9:0d:c5:12:a9 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 56:81:44:02:b6:80 brd ff:ff:ff:ff:ff:ff
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:f3:46:0d brd ff:ff:ff:ff:ff:ff
    inet 172.18.49.8/28 brd 172.18.49.15 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fef3:460d/64 scope link
       valid_lft forever preferred_lft forever
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0

manukyae@GNELTCG8424MZX:~$ ip route show
default via 172.18.49.1 dev eth0
172.18.49.0/28 dev eth0 proto kernel scope link src 172.18.49.8

manukyae@GNELTCG8424MZX:~$ traceroute 1.1.1.1

Command 'traceroute' not found, but can be installed with:

sudo apt install inetutils-traceroute
sudo apt install traceroute

manukyae@GNELTCG8424MZX:~$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.18.49.1
manukyae@GNELTCG8424MZX:~$

@j-fbriere
Copy link

j-fbriere commented Jan 14, 2021

The same problem has appeared today for me after the last Windows update kb4598242.
On Windows 10 Pro 2004 build 19041.746
There is no VPN.

>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 7e:31:83:f9:51:56 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
  link/ether 2a:9f:8a:73:1e:5f brd ff:ff:ff:ff:ff:ff
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
  link/ether 00:15:5d:a3:40:85 brd ff:ff:ff:ff:ff:ff
  inet 172.29.17.34/20 brd 172.29.31.255 scope global eth0
     valid_lft forever preferred_lft forever
  inet6 fe80::215:5dff:fea3:4085/64 scope link
     valid_lft forever preferred_lft forever
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
  link/sit 0.0.0.0 brd 0.0.0.0
      
>ip route show
default via 172.29.16.1 dev eth0
172.29.16.0/20 dev eth0 proto kernel scope link src 172.29.17.34

>traceroute 1.1.1.1

Command 'traceroute' not found, but can be installed with:

sudo apt install inetutils-traceroute
sudo apt install traceroute

>cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.29.16.1

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 14, 2021

Thank you for the info @armenic .

It looks like traceroute isn't installed, and without an internet connection, you can't install it, so can you please the share the output of the following:

  • ping 1.1.1.1
  • ping $(ip route show | awk '/default/ { print $3 }')

What I'm trying to figure out is if this is a DNS or a routing issue.

@j-fbriere
Copy link

j-fbriere commented Jan 14, 2021

Just to give an update.
I uninstalled the security Windows update kb4598242. Then reboot.
Then it reinstalled itself. Then reboot.
And now I have access to internet again on my WSL-2 Ubuntu 18.04.5 LTS!

@armenic
Copy link
Author

armenic commented Jan 15, 2021

@OneBlue, I have a feeling that you are going to get to the root cause! Here we go, as you requested:

manukyae@GNELTCG8424MZX:~$ ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=23.6 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=56 time=20.1 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=56 time=19.6 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=56 time=23.9 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=56 time=19.1 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=56 time=28.7 ms
64 bytes from 1.1.1.1: icmp_seq=7 ttl=56 time=19.8 ms
64 bytes from 1.1.1.1: icmp_seq=8 ttl=56 time=20.2 ms
64 bytes from 1.1.1.1: icmp_seq=9 ttl=56 time=20.2 ms
64 bytes from 1.1.1.1: icmp_seq=10 ttl=56 time=19.6 ms
64 bytes from 1.1.1.1: icmp_seq=11 ttl=56 time=21.1 ms
64 bytes from 1.1.1.1: icmp_seq=12 ttl=56 time=20.6 ms
64 bytes from 1.1.1.1: icmp_seq=13 ttl=56 time=20.4 ms
64 bytes from 1.1.1.1: icmp_seq=14 ttl=56 time=20.1 ms
64 bytes from 1.1.1.1: icmp_seq=15 ttl=56 time=20.2 ms
^C
--- 1.1.1.1 ping statistics ---
15 packets transmitted, 15 received, 0% packet loss, time 14025ms
rtt min/avg/max/mdev = 19.153/21.202/28.747/2.413 ms

manukyae@GNELTCG8424MZX:~$ ping $(ip route show | awk '/default/ { print $3 }')
PING 172.18.49.1 (172.18.49.1) 56(84) bytes of data.
64 bytes from 172.18.49.1: icmp_seq=1 ttl=128 time=0.476 ms
64 bytes from 172.18.49.1: icmp_seq=2 ttl=128 time=0.477 ms
64 bytes from 172.18.49.1: icmp_seq=3 ttl=128 time=0.487 ms
64 bytes from 172.18.49.1: icmp_seq=4 ttl=128 time=0.594 ms
64 bytes from 172.18.49.1: icmp_seq=5 ttl=128 time=0.680 ms
64 bytes from 172.18.49.1: icmp_seq=6 ttl=128 time=0.626 ms
64 bytes from 172.18.49.1: icmp_seq=7 ttl=128 time=0.822 ms
64 bytes from 172.18.49.1: icmp_seq=8 ttl=128 time=0.664 ms
64 bytes from 172.18.49.1: icmp_seq=9 ttl=128 time=0.757 ms
64 bytes from 172.18.49.1: icmp_seq=10 ttl=128 time=0.684 ms
64 bytes from 172.18.49.1: icmp_seq=11 ttl=128 time=0.602 ms
64 bytes from 172.18.49.1: icmp_seq=12 ttl=128 time=0.547 ms
64 bytes from 172.18.49.1: icmp_seq=13 ttl=128 time=0.580 ms
64 bytes from 172.18.49.1: icmp_seq=14 ttl=128 time=0.579 ms
64 bytes from 172.18.49.1: icmp_seq=15 ttl=128 time=0.703 ms
^C
--- 172.18.49.1 ping statistics ---
15 packets transmitted, 15 received, 0% packet loss, time 14531ms
rtt min/avg/max/mdev = 0.476/0.618/0.822/0.101 ms
manukyae@GNELTCG8424MZX:~$

@armenic armenic changed the title wsl2 no internet access on windows 1909 build 18363.1139 wsl2 no internet access (unable to resolve host address) on windows 1909 build 18363.1139 Jan 15, 2021
@armenic
Copy link
Author

armenic commented Jan 15, 2021

just to be helpful in case this is DNS issue, the wget output that was supposed to download the file:

manukyae@GNELTCG8424MZX:/mnt/c/Users/manukyae$ wget http://wordpress.org/latest.tar.gz
--2021-01-14 21:35:52--  http://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘wordpress.org’
manukyae@GNELTCG8424MZX:/mnt/c/Users/manukyae$

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 15, 2021

@armenic: Yes, something is clearly wrong with DNS.

Can you share the output of cat /etc/resolv.conf, and then try to replace 'nameserver X.X.X.X' by 'nameserver 1.1.1.1' in that file and check if the wget command succeeds after doing that ?

@armenic
Copy link
Author

armenic commented Jan 15, 2021

here we go my friend (@OneBlue), anything you say:

original state

manukyae@GNELTCG8424MZX:~$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.18.49.1

after change which I guess did not help :(

manukyae@GNELTCG8424MZX:~$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 1.1.1.1
manukyae@GNELTCG8424MZX:~$ wget http://wordpress.org/latest.tar.gz
--2021-01-14 22:11:01--  http://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘wordpress.org’

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 15, 2021

Thank you @armenic.

This is interesting, ICMP works, but IP doesn't. This appears to be a routing issue, so I'm gonna need to collect some logs and have a deeper look at what's happening.

I know that you can't use Feedback Hub, so can you please follow the Record WSL logs manually section I just created and share the log file ?

(Note: the PR isn't merged yet, so the wprp file needs to be downloaded from here)

@armenic
Copy link
Author

armenic commented Jan 15, 2021

dear @OneBlue, thank you so much for diligently working on this issue. I followed your instructions and the generated wsl.etl is attached. Please note that I had to zip it so that GitHub allows attaching. Good luck with your investigation!
wsl.zip

@killshot13
Copy link

killshot13 commented Jan 16, 2021

windows_specs

@OneBlue @armenic very similar situation here. I have already taken the following steps:

  1. Deleted Docker Desktop
  2. Deleted Ubuntu application.
  3. Uninstall WSL2 update.
  4. Troubleshooting network connection.
  5. Checked running services and dependencies for any glaring errors.
  6. Performed a complete re-install of WSL2 according to this guide.
  7. Tested with VPN disabled; tested with VPN & Internet disabled.

wsl_error_ps_view

vsCode_wsl2_error

vsCode_wsl2_noInternetJPG

Please advise how to proceed; I am a Windows Insider in the beta channel and my machine is fully up-to-date. I have Feedback Hub locally installed and I am familiar with provided feedback and performing diagnostic captures. Anything you need as far as analytics is concerned, I am happy to provide.

This is very important for me to get fixed because during this past summer I moved my dev environment over to WSL 2 almost exclusively. I am a professional JavaScript/web developer so I have upcoming deadlines/commitments to several clients/companies, and without this functionality, my productivity is quite trivial. Thank you in advance!

@killshot13
Copy link

Custom Diagnostic Logs

@drkvogel
Copy link

@killshot13 I use WSL2 and haven't had this issue, but have had an issue with the clock: #5324 - at least one of two things I did seemed to fix that issue: 1) Upgrading from Ubuntu 18.04 to 20.04, and 2) Switching from the Windows Insider Beta channel back to the Windows Preview channel. I also had random green screen system crashes on the Beta channel.

As you've reinstalled Ubuntu - it seems that sometimes a distro needs to be re-registered with WSL, either by upgrading/reinstalling or by forcing it with wsl --unregister <DistroName>, then wsl --set-default <DistroName> - maybe that's not the problem - but have you tried going back to the Preview channel? Just a shot in the dark to try, perhaps.

My winver is 20H2 19042.746.

@killshot13
Copy link

killshot13 commented Jan 16, 2021

@drkvogel I have not tried that yet; honestly I hadn't thought of it but it's certainly worth a shot. Stay tuned, and thank you!

@armenic
Copy link
Author

armenic commented Jan 16, 2021

@OneBlue, sorry to bother. Just to let you know that the same issue happens with any Linux distro + WSL2, I tried Ubuntu 20.04 LTS and Kali as well. Hopefully the solution for Ubuntu 18.04 will be applicable to all distros.

@WHTCoder
Copy link

尝试了centos,ubuntu,debain,都不可以,什么时候能解决这个问题呢?

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 23, 2021

@armenic : From what we can see in the logs, the issue appears to come from deeper in the stack, so we'll need more diagnostics.

I've updated the "networking issues" section with a new script that should gather everything we need.

Can you please run this script and share both the generated wsl.etl, and the script output ?

@killshot13: Please follow the same instructions so we can figure out if it's the same issue or not.

@armenic
Copy link
Author

armenic commented Jan 23, 2021

@OneBlue, thanks for follow-up. Both the output and wsl.etl are in the attached zip file. Please keep doing the great job!
networking_output_and_wsl.zip

@killshot13
Copy link

@OneBlue, thank you for getting back to us! Everything you requested should be available using this link. Please let me know if you encounter any difficulties or anomalies.

@Alslinet
Copy link

Having a similar if not the same exact issue. User has anyconnect VPN client. Disconnecting from VPN and closing WSL does not fix the issue for him either.

@Thadir
Copy link

Thadir commented Dec 13, 2021

is there any good solution, I'm behind a heavy VPN/Proxy setup and i do not maintain nor can I access. If I upgrade to WSL2 it doesn't work. I tried the VPN fix but its not a good approach. And from this ticket I do not get a feeling its being worked on. And its more a logging of workarounds and not a permanent fix.

@K2ouMais
Copy link

I don't think we will ever see a solution for this. It has been months and nothing has happened.

@lingyanmeng
Copy link

I met the same issue with VPN, and in my case, the root cause is the DNS resolution, wsl will update the /etc/resolv.conf automatically based on the network which is nameserver 192.168.1.1, and this nameserver is not right once I enable the VPN, so I followed the steps in https://superuser.com/questions/1533291/how-do-i-change-the-dns-settings-for-wsl2#, and changed to nameserver 8.8.8.8, then it works.

@Anonymous-Coward
Copy link

Anonymous-Coward commented Mar 14, 2022

Right now, I switch frequently between several VPNs, from different providers (Cisco, OpenVPN, Array Networks), each one with its own DNS servers. Disabling resolv.conf generation is therefore not an option for me.

What I do is hack my required hosts list together and add it to /etc/hosts (actually (c:\windows\system32\drivers\etc\hosts). This is ugly and error-prone - whenever IPs change for a VPN some things start breaking out of the blue.

From what I can tell, the DNS issue, which seems to be the root cause of this issue, is caused (at least for me) by the fact that the DNS servers provided by the VPNs are IPV6 only, and WSL 2 seems to have sketchy support for IPV6 (didn't dig too deep into it, though, but it seems no IPV6-only site is reachable from within WSL, except things running inside wsl on ::1).

@nikodemus
Copy link

Had this issue on Windows 11, changing the nameserver to 1.1.1.1 as per https://superuser.com/questions/1533291/how-do-i-change-the-dns-settings-for-wsl2# fixed it for me.

@weeezes
Copy link

weeezes commented Mar 28, 2022

Had this issue when I updated to Windows 11, /etc/resolv.conf was empty and everything started to work after creating it and adding the nameserver settings to it.

@themarquee
Copy link

I have been using WSL2 on Windows 10 with Ubuntu 20.04 for months. After a recent system update (corporate-managed) I am experiencing this issue. No nameserver entry for resolv.conf seems to work. We must use Cisco AnyConnect. I cannot ping any of the nameservers by IP either. Anyone have any other advice? I am back to using my Virtualbox VM now. 😕

@themarquee
Copy link

themarquee commented Jul 5, 2022

I have been using WSL2 on Windows 10 with Ubuntu 20.04 for months. After a recent system update (corporate-managed) I am experiencing this issue. No nameserver entry for resolv.conf seems to work. We must use Cisco AnyConnect. I cannot ping any of the nameservers by IP either. Anyone have any other advice? I am back to using my Virtualbox VM now. 😕

This link seemed to fix it for me. https://community.cisco.com/t5/vpn/anyconnect-wsl-2-windows-substem-for-linux/td-p/4179888. I created a powershell script to run the firewall commands on startup 🤮

@natank
Copy link

natank commented Jul 6, 2022

I had the same issue and used below code in my /etc/resolv.conf and worked
nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver fec0:0:0:ffff::1 search lan

I stumbled across the same problem today setting up WSL2 on my company controlled machine. This suggestion fixed it for me.

EDIT: The system overwrites this configuration after a few minutes. To fix that, I just set up a cron job running every minute to set this configuration again. For now it works like a charme :) I'm no linux expert to know possible side effects of this, I just wanted to share a solution to annoyingly resetting this whenever you need to download a package 😄

worked for me

@ssgosh
Copy link

ssgosh commented Jul 31, 2022

Facing this issue on Windows 11 after a recent update. OS Build 22000.795.

@ssgosh
Copy link

ssgosh commented Jul 31, 2022

Got fixed after updating again to OS Build 22000.832

@PeterFogh
Copy link

PeterFogh commented Aug 17, 2022

I just installed WSL2 on a Windows version: 21H2 - build: 19044.1889

The WSL could not solve domain names, thus the DNS IP was not configured by default. I just followed this guide https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6 which solved the DNS.

@sonvirgo
Copy link

Same here, with wsl2 on windows 11 22h2. Ubuntu suddenly refuses to resolve hosts after few days. Softether VPN and SSTap.

@davidhyland
Copy link

davidhyland commented Oct 13, 2022

I had the same issue and used below code in my /etc/resolv.conf and worked ` nameserver 8.8.8.8

nameserver 8.8.4.4

nameserver fec0:0:0:ffff::1

search lan `

Running WSL2 and Docker I had this problem a couple of weeks ago immediately after updating to 22H2. I couldn't find a solution so I had to roll back the update. Just tried updating again and the same issue occured. Started searching again and found this thread. This solution from @rezarms worked for me.

UPDATE - The resolv.conf file gets reset automatically from time to time so adding the following to /etc/wsl.conf seems to sort that out:

[network]
generateResolvConf = false

@UncleCJ
Copy link

UncleCJ commented Oct 20, 2022

Not sure why it would be pertinent, but this has occurred intermittently to me - and it effectively was remedied when I disabled sharing my WiFi interface from Windows (was shared to hosts on ethernet during today...)

Do any of you other happen to have network interfaces shared in Windows?

@sonvirgo
Copy link

There must be a DNS timeout setting somewhere. Both Wsl2 and WSA on my Windows 22h2 only resolve Urls after 2nd or 3rd try, each waist a click away.

@felipe-gustavo
Copy link

It doesn't make sense to me, 'cause when I restart my PC and run to test it (I guess, before some adapter of configuration be set) it works, but after this it just give up, I'm going to 3th week with this issue :/

image

@castrix
Copy link

castrix commented Nov 18, 2022

I just had this issue, this comes out of the blue, yesterday it was working fine, but suddenly I can't pull from github/bitbucket, tried the suggestion above, but nothing work in my case.

Edit: I shutdown my PC and turn it on again, somehow the issue is resolved. (previously I restarted my pc and it doesn't work, but shutdown somehow fixed it)

@sonvirgo
Copy link

sonvirgo commented Nov 18, 2022

The most recent solution work for me from here coltenkrauter/fix-wsl2-dns-resolution

@ilyesAj
Copy link

ilyesAj commented Dec 20, 2022

from my side the root cause was macfee , #8382 , i m disabling the firewall until figuring out some rules

@jerrychong25
Copy link

Fixed it by reboot WSL in PowerShell, then DNS works again.

@PlasmaHH
Copy link

It seems there are two seperate issues here. Some can just not resolve dns entries, for some no internet access at all. Like for me, even pinging 8.8.8.8 woudln't work. DId a "netsh winsock reset" as suggested above and it worked. Also it should be said that WSL1 works fine.

@austin-dorff-gainwell
Copy link

@armenic: Yes, something is clearly wrong with DNS.

Can you share the output of cat /etc/resolv.conf, and then try to replace 'nameserver X.X.X.X' by 'nameserver 1.1.1.1' in that file and check if the wget command succeeds after doing that ?

This immediately resolved my issue. Thank you!!!

@Edwardhk
Copy link

Edwardhk commented May 14, 2023

Easy fix for me just running, because I have install some VPN software, such as EasyConnect

netsh winsock reset

then restart computer, everything goes to be OK.

Much thanks, works for me!

For reference, my winver: Win10 Version 1909 (OS Build 18363.1556)

@mariolucasdev
Copy link

I had a similar problem with name resolution within wsl2.

I solved the problem by just adding the local domain to my windows host file at

c:/windows/system32/drives/etc/host

@mrjaphroiag
Copy link

a very quick fix that worked on my machine is to set /etc/resolv.conf to just use Googles root DNS server. This won't work in environments where you need internal resolution, which may or may not work with @mariolucasdev 's solution. It is just really, really specific to the environment.

nameserver 8.8.8.8

@noragalvin
Copy link

noragalvin commented Feb 12, 2024

@armenic: Yes, something is clearly wrong with DNS.

Can you share the output of cat /etc/resolv.conf, and then try to replace 'nameserver X.X.X.X' by 'nameserver 1.1.1.1' in that file and check if the wget command succeeds after doing that ?

I dont know why my resolv.conf have the config like nameserver 127.0.2.x after adding the networkingMode=mirrored in .wslconfig. I have changed it to 1.1.1.1 and it works. Thank you

@Jokcy
Copy link

Jokcy commented Feb 29, 2024

For anyone try to manually set the nameservers by editing /etc/resolv.conf, you may found that it will be recoved after wsl reboot. To fix this, you can create a /etc/wsl.conf file and input:

[network]
generateResolvConf = false

To me set this in windows side does not work, I can only make it work by setting this in wsl side.

@adenafil
Copy link

adenafil commented Apr 5, 2024

i fix this issue by setting file in /retc/resolv.conf like below

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:        
# [network]
# generateResolvConf = false
nameserver "Your Host or ip gateway"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests