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

Unable to resolve domain names on WSL #5584

Closed
BMXsanko opened this issue Jul 14, 2020 · 11 comments
Closed

Unable to resolve domain names on WSL #5584

BMXsanko opened this issue Jul 14, 2020 · 11 comments
Labels

Comments

@BMXsanko
Copy link

Windows build number: Microsoft Windows [Version 10.0.19041.329]

Nslookup can resolve the domain but ping can't, It was working a day before (I think there was a windows update), I turned off my computer, after that it stopped working. (I have tried adding a new WSL (different version of ubuntu) it still does it on a fresh install as well.
In the screen below you can see that I can ping the actual IP that was resolved by nslookup for google.com but ping (and any other app on the system is unable to resolve the domain names)
image

@benhillis
Copy link
Member

What is the contents of /etc/resolv.conf?

@gtmsingh
Copy link

I faced similar issue. As mentioned by @benhillis the content of /etc/resolv.conf in WSL only had this: nameserver 172.80.X.Y.

I changed it to:

nameserver 8.8.8.8
nameserver 172.80.X.Y

Now I was able to ping different websites.

@tchang1997
Copy link

Just wanted to boost this -- I've reproduced/experienced this problem on Insider Build 20190.1000 (fast ring), Ubuntu 18.04. I utilized the same fix -- adding nameserver 8.8.8.8 to the top of the list of DNS servers in /etc/resolv.conf, and ping, ssh work as expected now.

@BMXsanko
Copy link
Author

I have the nameserver 8.8.8.8 added to /etc/resolv.conf also added generateResolvConf = false to /etc/wsl.conf this way i can do nslookup without this nslookup doesn't work, but ping still does't work, for now what I am doing is manually adding items to /etc/hosts this way it works but its only a temporary solution.

@timriker
Copy link

I suspect this is a duplicate of #5806

@lukee1234
Copy link

If you modified, moved or compressed the temp folder, look at #5437 for the solution

@timriker
Copy link

Hardcoding /etc/resolv.conf is not a great solution if you use VPN tunnels or move around to different networks. I can't reach 8.8.8.8 when I'm on VPN or on my internal corporate network. I want resolv.conf to point to the windows resolution so that VPN / internal networks would transparently to the WSL image. I don't do this currently as #5806 causes incorrect DNS responses when using the WSL DNS proxy. DNS search paths are not propagated #701 and VPN changes are not either #1350.
Overall, DNS is poorly supported by WSL.

@svenluijten
Copy link

Thanks for confirming my suspicions @timriker! (And understanding that hardcoding nameservers in /etc/resolv.conf is barely a solution!) Looks like there's nothing that can be done as I'm still experiencing this issue 2 months after your comment. So be it, I guess...

@MWatter
Copy link

MWatter commented Jul 26, 2021

I've searched dozens of tickets and this one appears to be the most closely aligned with the issues I've seen and I have additional information that may (or more likely, may not) be helpful.

I installed WSL2 on a clean machine. Immediately upon starting up I encountered the same issue as many others with no DNS resolution. This is easily, although awkwardly, solved by preventing resolv.conf auto-generation and hard coding an external DNS server. This allows normal internet operations on the WSL2 instance.

The core problem, at least in my case, isn't that there isn't a DNS resolver at the WSL2 host adapter address (there may or may not be; no idea), it's that the WSL2 instance cannot communicate with the host Windows 10 instance using the host's WSL adapter IP address.

I have opened the Windows 10 Firewall to ICMP from anywhere for testing and have a TCP server running there that can be reached on port 6001 (Firewall also opened to allow connections to that port). The WSL2 instance CAN reach the windows machine using the network IP assigned by my router (192.168.0.xxx) but it cannot reach the host using the WSL adapter IP. Neither ping nor a nc -vz xxx.xxx.xxx.xxx 6001 (the port the server is running on) connection will work. For all intents and purposes the Windows 10 host is hidden from the WSL2 instance on that specific IP.

Interestingly, I can ping and connect to that IP from the host itself so the network adapter is activated and seemingly reachable. One might think firewall, but nothing changes even with the firewall disabled.

I am working around this but it does make tools that rely on this connection (VS Code and more importantly for me, The Intellij IDEA WSL2 integration) non-functional.

@Alino
Copy link

Alino commented Jun 28, 2022

I run into this issue just now, but figured out that it was related to this Cisco anyConnect VPN issue https://community.cisco.com/t5/vpn/anyconnect-wsl-2-windows-substem-for-linux/td-p/4179888

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

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

10 participants