microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.44k stars 821 forks source link

DNS not working in fresh Ubuntu 18.04 that installed from Windows Store #3268

Closed VMatrix1900 closed 5 months ago

VMatrix1900 commented 6 years ago

ping xxx.xxx.xxx.xxx works fine, but ping baidu.com does not work.

ifconfig returns following result:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.62.113  netmask 255.255.255.240  broadcast 172.17.62.127
        inet6 fe80::388c:7783:48bc:85c5  prefixlen 64  scopeid 0x0<global>
        ether a6:15:d1:58:04:82  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.192  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2402:f000:9:ce01:3520:9468:2982:8e90  prefixlen 64  scopeid 0x0<global>
        inet6 2402:f000:9:ce01:c086:34b5:b28a:6a5a  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::3520:9468:2982:8e90  prefixlen 64  scopeid 0x0<global>
        ether 1c:1b:0d:82:76:36  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 1500
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x0<global>
        loop  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sudo systemctl status resolvconf returns:

System has not been booted with systemd as init system (PID 1). Can't operate.

The content of /etc/resolv.conf is:

# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
nameserver 192.168.1.1
nameserver fec0:0:0:ffff::1
nameserver fec0:0:0:ffff::2
search lan

192.168.1.1 is my router's ip address.

At the same time, everything works fine in Ubuntu 16.04 installed from Windows Store works fine.

onewnan commented 5 years ago

I had lost track that I installed the Zonealarm firewall and then subsequently installed Norton Network Security. Disabling Zonealarm solved my problem in using DNS. My thanks to those who tried to help me resolve this.

paulochf commented 5 years ago

I got aware of other issues like this one caused by firewalls as @onewnan said.

Moreover, I would like to know if there's any solution for those who don't have access to firewall configs (i.e. people using companies laptops which doesn't have admin access).

coralnode commented 5 years ago

Closing Kaspersky antivirus fixed the issue for me.

JanPokorny commented 5 years ago

Hello, I have encountered the same issue. After clean install of Ubuntu from the store, DNS resolution does not work (eg. apt update fails). My /etc/resolv.conf is empty except for the comment # This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.. Adding nameserver 8.8.8.8 to the file immediately fixes the problem, but is not permanent -- even after removing the comment, the file is still regenerated.

The complete process:

xpokorn3@PUF-LENOVO:~$ sudo apt update
[sudo] password for xpokorn3:
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
  Temporary failure resolving 'archive.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.
xpokorn3@PUF-LENOVO:~$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
xpokorn3@PUF-LENOVO:~$ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
nameserver 8.8.8.8
xpokorn3@PUF-LENOVO:~$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Fetched 252 kB in 4s (58.7 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
xpokorn3@PUF-LENOVO:~$

The only working permanent workaround I have found is:

sudo rm /etc/resolv.conf
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
sudo chmod 444 /etc/resolv.conf

This seems to be successfully preserved after restarts of WSL.

nhoclove commented 5 years ago

It seems that apt does not use the system proxy. So I set proxy for apt in /etc/apt/apt.conf. For proxy with no authentication required:

Acquire::http::proxy "http://<proxy-server>:<proxy-port>";
Acquire::https::proxy "http://<proxy-server>:<proxy-port>";
Acquire::ftp::proxy "http://<proxy-server>:<proxy-port>";

For proxy with authentication required:

Acquire::http::proxy "http://<user>:<pass>@<proxy-server>:<proxy-port>";
Acquire::https::proxy "http://<user>:<pass>@<proxy-server>:<proxy-port>";
Acquire::ftp::proxy "http://<user>:<pass>@<proxy-server>:<proxy-port>";

After that run sudo apt-get update. It should work fine with WSL window 10.

JanPokorny commented 5 years ago

@nhoclove Sadly, for me the problem is occurring without ever using a proxy. Also, it affects all programs, not just apt.

rellbits commented 5 years ago

Reporting the same issue. apt-get command cannot resolve the DNS addresses. Shows Temporary failure resolving... error. ping 8.8.8.8 works on WSL and cmd/PowerShell. ping google.com does NOT work on WSL, only works on cmd/PowerShell. Updated Windows 10 to version 1809 - did not help. Disabled and enabled WSL - did not help. Installed Ubuntu, Ubuntu 18.04 and Ubuntu 16.04 - same error for all versions. Do not have Kaspersky or similar software installed on this machine.

tigerrrr commented 5 years ago

Reporting the same issue. apt-get command cannot resolve the DNS addresses. Shows Temporary failure resolving... error. ping 8.8.8.8 works on WSL and cmd/PowerShell. ping google.com does NOT work on WSL, only works on cmd/PowerShell. Updated Windows 10 to version 1809 - did not help. Disabled and enabled WSL - did not help. Installed Ubuntu, Ubuntu 18.04 and Ubuntu 16.04 - same error for all versions. Do not have Kaspersky or similar software installed on this machine.

I just fixed it today by updating Windows 10 to Version 1903.

Airwise commented 5 years ago

I have the same issue on Ubuntu 18.04 WITH Version 1903 of WSL. Can ping ip addresses. But pinging "google.com" gives: Temporary failure in name resolution.

nslookup gives a valid google ip address. So does dig.

Ubuntu 16.04 produces same result (but error is ping: unknown host google.com)

openSUSE Leap 15.1 behaves the same as Ubuntu 18.04

Debian 9 produces same result (For ping. It doesn't come with nslookup and I can't install it without DNS resolution.)

Pengwin is the same as Debian 9

Alpine 3.9 works (can ping "google.com" as super user)

rellbits commented 5 years ago

Reporting the same issue. apt-get command cannot resolve the DNS addresses. Shows Temporary failure resolving... error. ping 8.8.8.8 works on WSL and cmd/PowerShell. ping google.com does NOT work on WSL, only works on cmd/PowerShell. Updated Windows 10 to version 1809 - did not help. Disabled and enabled WSL - did not help. Installed Ubuntu, Ubuntu 18.04 and Ubuntu 16.04 - same error for all versions. Do not have Kaspersky or similar software installed on this machine.

I just fixed it today by updating Windows 10 to Version 1903.

Just updated to version 1903, still getting the same error.

aztack commented 5 years ago

try sudo vi /etc/resolv.conf

nameserver 8.8.8.8 nameserver 8.8.4.4

anteyk commented 5 years ago

I got same problem when I use VPN connection through OpenVPN. When I disconnect VPN name resolution works properly.

Airwise commented 5 years ago

I've altered /etc/resolv.conf to point to google name servers. I don't use a VPN. The issue remains. I suspect it is some other application I have installed on Windows that is intercepting the DNS queries (I'm using things that might mess with the networking on my machine like proxycap, cygwin, webroot, docker desktop, vmware, etc- though vmware is turned off to enable HyperV). I plan to do a fresh Windows install as soon as I have a half-day free and I'll test the WSL early before I install any of the other cruft to confirm or disprove that hypothesis.

If it works, that wouldn't really explain why nslookup and dig can resolved hostnames while other networking applications cannot- but hope springs eternal in the human breast.

This is on a Dell XPS 15 9560 by the way. Just in case it ends up being hardware specific.

UPDATE A clean install and incremental addition of my usual programs helped me narrow in on the culprit. It is ProxyCap. ProxyCap is an application that sniffs your network traffic and if the destination host matches one you've configured- it establishes a proxy (SSH tunnel to my company's remote servers in my case) to that host and routes the traffic over that proxy. All other traffic it is supposed to let through. But for whatever reason it appears to NOT let whatever DNS requests that ping and package managers use through to the internet- for linux distros that aren't Alpine. Bizarre and random, but just one of those things I guess.

rellbits commented 5 years ago

I've just changed my Internet Service Provider and suddenly everything works. Even on different machines with different Windows 10 Versions. Maybe it was some configuration on my old modem/router ? This issue is just weird.

UPDATE: For my case, I've managed to find a fix since I still have my old Internet service available. It was a bad default configuration on my old Wireless Router. It had as Primary and Secondary DNS the default value of 0.0.0.0. ipconfig /all will show 192.168.1.1 as value for DNS Servers, which doesn't work for WSL. Replaced thoses values with my ISP ones and the DNS error on Ubuntu is gone.

TSNord commented 5 years ago

I found this bug when using openvpn with options:

dhcp-option DNS 10.10.1.1 register-dns block-outside-dns

After disconnecting from ovpn server WSL working normally.

detuur commented 5 years ago

I've run into the same problem. Occurs when having a Wireguard tunnel open at the same time, even if that tunnel is only for non-internet traffic. In my case, I had a wg tunnel to 192.168.10.0/24 for dev servers.

Deactivating the tunnel immediately resolves the issue. Activating the tunnel immediately breaks WSL again.

coltenkrauter commented 5 years ago

This worked for me

Fix DNS resolution in WSL2

tautomer commented 5 years ago

Indeed the apt-get command cannot resolve the DNS addresses.

Could you try the answer as provided in this question - https://askubuntu.com/questions/91543/apt-get-update-fails-to-fetch-files-temporary-failure-resolving-error

This one worked for me. (WSL1) There wasn't anything in /etc/resolv.conf somehow, which caused the problem that no domain could be resolved.

bilalcaliskan commented 4 years ago

I have resolved my issue by deleting Checkpoint VPN Client. Now it works correctly.

rm-bergmann commented 4 years ago

I am experiencing the same issue, and I have tried every suggestion. I am on WIFI only, no LAN. Windows version: Build 19025

ipconfig output:

Wireless LAN adapter WiFi:

   Connection-specific DNS Suffix  . : Home
   IPv6 Address. . . . . . . . . . . : fd47:b963:1da7:0:8951:1ad5:aefb:f41f
   Temporary IPv6 Address. . . . . . : 2a02:c7f:a5b:7a00:c8e9:ab:afc0:78d4
   Temporary IPv6 Address. . . . . . : fd47:b963:1da7:0:5dd9:74a7:fcdc:a16d
   Link-local IPv6 Address . . . . . : fe80::8951:1ad5:aefb:f41f%4
   IPv4 Address. . . . . . . . . . . : 192.168.0.2
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::26a7:dcff:fede:6109%4
                                       192.168.0.1

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::e576:434b:8973:dc9e%47
   IPv4 Address. . . . . . . . . . . : 172.20.112.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

wsl2 ifconfig output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.20.116.125  netmask 255.255.240.0  broadcast 172.20.127.255
        inet6 fe80::215:5dff:fe0f:f5e6  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:0f:f5:e6  txqueuelen 1000  (Ethernet)
        RX packets 820  bytes 77242 (77.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 248  bytes 19800 (19.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

/etc/resolv.conf has this IP: (I also tried 8.8.8.8) nameserver 172.20.112.1

Default gateway is empty for Ethernet adapter vEthernet (WSL). Is that the problem or is it because the ip address in eth0 (172.20.116.125) is different from the WSL ethernet ip address (172.20.112.1)?

rellbits commented 4 years ago

I am experiencing the same issue, and I have tried every suggestion. I am on WIFI only, no LAN. Windows version: Build 19025

ipconfig output:

Wireless LAN adapter WiFi:

   Connection-specific DNS Suffix  . : Home
   IPv6 Address. . . . . . . . . . . : fd47:b963:1da7:0:8951:1ad5:aefb:f41f
   Temporary IPv6 Address. . . . . . : 2a02:c7f:a5b:7a00:c8e9:ab:afc0:78d4
   Temporary IPv6 Address. . . . . . : fd47:b963:1da7:0:5dd9:74a7:fcdc:a16d
   Link-local IPv6 Address . . . . . : fe80::8951:1ad5:aefb:f41f%4
   IPv4 Address. . . . . . . . . . . : 192.168.0.2
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::26a7:dcff:fede:6109%4
                                       192.168.0.1

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::e576:434b:8973:dc9e%47
   IPv4 Address. . . . . . . . . . . : 172.20.112.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

wsl2 ifconfig output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.20.116.125  netmask 255.255.240.0  broadcast 172.20.127.255
        inet6 fe80::215:5dff:fe0f:f5e6  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:0f:f5:e6  txqueuelen 1000  (Ethernet)
        RX packets 820  bytes 77242 (77.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 248  bytes 19800 (19.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

/etc/resolv.conf has this IP: (I also tried 8.8.8.8) nameserver 172.20.112.1

Default gateway is empty for Ethernet adapter vEthernet (WSL). Is that the problem or is it because the ip address in eth0 (172.20.116.125) is different from the WSL ethernet ip address (172.20.112.1)?

What's the output for DNS Servers when you type "ipconfig /all" in powershell? Does it show the correct values?

rm-bergmann commented 4 years ago

I don't understanding networking very well, so diffiuclt for me to say if all of this is correct. I see that DHCP is disabled on the wsl adapter, I'm not sure if it should be enabled.

Here's the output of ipconfig /all (I've removed the irrelevant adapter information like bluetooth adapter)

Windows IP Configuration

   Host Name . . . . . . . . . . . . : RMB-Dev-Host
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : Home

Wireless LAN adapter WiFi:

   Connection-specific DNS Suffix  . : Home
   Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 3165
   Physical Address. . . . . . . . . : 98-54-1B-FB-70-A2
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv6 Address. . . . . . . . . . . : 2a02:c7f:a5b:7a00:8951:1ad5:aefb:f41f(Preferred)
   IPv6 Address. . . . . . . . . . . : fd47:b963:1da7:0:8951:1ad5:aefb:f41f(Preferred)
   Temporary IPv6 Address. . . . . . : 2a02:c7f:a5b:7a00:3962:5d74:3382:3988(Preferred)
   Temporary IPv6 Address. . . . . . : fd47:b963:1da7:0:3962:5d74:3382:3988(Preferred)
   Temporary IPv6 Address. . . . . . : fd47:b963:1da7:0:5dd9:74a7:fcdc:a16d(Deprecated)
   Link-local IPv6 Address . . . . . : fe80::8951:1ad5:aefb:f41f%4(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.0.2(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : 23 November 2019 19:50:55
   Lease Expires . . . . . . . . . . : 25 November 2019 19:06:18
   Default Gateway . . . . . . . . . : fe80::26a7:dcff:fede:6109%4
                                       192.168.0.1
   DHCP Server . . . . . . . . . . . : 192.168.0.1
   DHCPv6 IAID . . . . . . . . . . . : 43537435
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-5E-3C-C9-3C-52-82-11-6C-DA
   DNS Servers . . . . . . . . . . . : fd47:b963:1da7:0:26a7:dcff:fede:6108
                                       192.168.0.1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-15-5D-D1-97-D3
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::e576:434b:8973:dc9e%47(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.20.112.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 788534621
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-5E-3C-C9-3C-52-82-11-6C-DA
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled
rellbits commented 4 years ago

I don't understanding networking very well, so diffiuclt for me to say if all of this is correct. I see that DHCP is disabled on the wsl adapter, I'm not sure if it should be enabled.

Here's the output of ipconfig /all (I've removed the irrelevant adapter information like bluetooth adapter)


Wireless LAN adapter WiFi:

   DNS Servers . . . . . . . . . . . : fd47:b963:1da7:0:26a7:dcff:fede:6108
                                       192.168.0.1

Ethernet adapter vEthernet (WSL):

   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1

Well, thoses aren't the right addresses for DNS Servers. I can only suggest you what worked for me. Log into your router and find what is configured for Primary and Secondary DNS Servers. If it is empty, you can try adding Google's Public DNS IP addresses or your ISP's Public DNS IP addresses, whichever works. Do an "ipconfig /all" to see if there was any change for DNS Servers.

rm-bergmann commented 4 years ago

@rellbits I have checked my router config and it already has my ISP DNS servers set for primary and secondary. That's the default and can't be changed.

I tried to turn off Enable IPv6 on LAN side and Enable IPv6 DHCP Server but that didn't change the WSL DNS Servers. I can't see any other advanced settings to change.

I'm not sure how the WSL DNS Servers get those addresses, but I'll look into more about that. Thank you for pointing me in the right direction.

EDIT I went into network & sharing center, right clicked on vEthernet WSL Adapter, clicked properties, selected Internet Protocol Version 4 (TCP/IPv4), clicked Properties. In there I can set Google's DNS 8.8.8.8 & 8.8.4.4. Did the same for Wireless LAN adapter.

Now in Powershell ipconfig/all displays Google's DNS addresses, but this still does not fix the problem. I will keep trying differemt config and solutions and update here if I find something.

Wireless LAN adapter WiFi: 
DNS Servers . . . . . . . . . . . : 8.8.8.8
                                    8.8.4.4 
Ethernet adapter vEthernet (WSL):
   DNS Servers . . . . . . . . . . . : 8.8.8.8
                                       8.8.4.4
zhixiangjoy commented 4 years ago

today, I meet the same problem, all domain in wsl will resolve to 192.168.0.52 ,This is not correct. I don't konw what's wrong. image image image Finally,I edit /etc/resolv.conf ,I ease the nameserver 127.0.0.1 53, use the public dns server and everything looks fine .

Last, I find this in cause by EasyConnect that a ssl vpn clinet made by Sangfor(http://www.sangfor.com.cn/),Which will modify windows local DNS server to 127.0.0.1:53 to it DNS process.

kommersz commented 4 years ago

The issue seems to correlate with truncation of UDP DNS responses, at least in my case - all DNS responses that are reported by nslookup as trucated are triggering the same "Temporary" resolution issue in ping (and node)

yanickgirouard commented 4 years ago

This issue is still ongoing. Fresh install of WSL Ubuntu 18.04 on Windows 10 Pro (v1709 build 16299.1625) done last week (15th of January). Same symptoms, can nslookup any domain, but pinging them is not working. Simply replacing the resolv.conf to use public DNS servers is not changing the outcome.

Curiously enough, on another PC with the same Windows version (it's a corporate image), WSL Ubuntu 18.04 was installed longer ago last year and maintained up to date every week (apt-get update; apt-get upgrade; apt-get clean), and doesn't have the problem. This leads me to believe that something broke along the way. It would be interesting to try installing an older WSL package to see if that changes something, but I can only download the latest version (is there an archive somewhere?)

I also confirm that the problem doesn't exist with WSL Ubuntu 16.04. I just did a fresh install and DNS resolution was fine.

yanickgirouard commented 4 years ago

today, I meet the same problem, all domain in wsl will resolve to 192.168.0.52 ,This is not correct. I don't konw what's wrong.

image image image Finally,I edit /etc/resolv.conf ,I ease the nameserver 127.0.0.1 53, use the public dns server and everything looks fine . Last, I find this in cause by EasyConnect that a ssl vpn clinet made by Sangfor(http://www.sangfor.com.cn/),Which will modify windows local DNS server to 127.0.0.1:53 to it DNS process.

I don't believe your issue is related to this one. The symptoms are totally different.

errorcodevortex commented 4 years ago

Kali Linux, Ubunutu 18.04, and also Ubuntu 16.04 are all facing this problem so are completely unusable. for me unfortunately. I have tried several fixes with no luck, I hope that they can improve these apps. No ping to websites, temporary failure resolving on apt-get update. No antivirus. vpn, or firewall.

APIAutomationTest commented 4 years ago

just installed ubuntu 18.04 LTS after other versions were uninstalled. can't ping things. super weird. windows 10 build 17763

niklasholm commented 4 years ago

I also have this issue. Windows 10 1909 v18363.657, fresh install of Ubuntu from Windows Store, name resolution broken. Edited resolv.conf manually works around the issue, after apt dist-upgrade the issue persists.

windowsma commented 4 years ago

I got same problem when I use VPN connection through OpenVPN. When I disconnect VPN name resolution works properly.

i view this page for hours,until i see your posts i know it's becase of VPN。and then i find the solution。 vi ~/.bashrc ADD dnsfix () { /mnt/c/Windows/system32/ipconfig.exe /all | grep --color=auto "DNS Servers" | cut -d ":" -f 2 | grep --color=auto -e '^ [0-9]' | sed 's/^/nameserver/' | sudo tee /etc/resolv.conf > /dev/null } source it,and exec dnsfix

it works!

zhixiangjoy commented 4 years ago

today, I meet the same problem, all domain in wsl will resolve to 192.168.0.52 ,This is not correct. I don't konw what's wrong.

image image image Finally,I edit /etc/resolv.conf ,I ease the nameserver 127.0.0.1 53, use the public dns server and everything looks fine . Last, I find this in cause by EasyConnect that a ssl vpn clinet made by Sangfor(http://www.sangfor.com.cn/),Which will modify windows local DNS server to 127.0.0.1:53 to it DNS process.

I don't believe your issue is related to this one. The symptoms are totally different.

Sometimes, maybe the windows vpn clint like easyclinet will effect the dns conf in wsl.

chazt3n commented 4 years ago

This just happened to me. All changes pointed out here broke my setup - my fix was to remove anything custom I had done with nameserver, auto generate, etc and simply ensure my terminal was running as admin... I had the exact same symptoms described here so it's possible there's going to be at least one other person with this issue.

tonymorony commented 4 years ago

Faced same issue was not able to resolve github or ubuntu repos lets say from WSL - in my case it was corrupted /etc/resolv.conf (by default after installation it looked like something like that: @@@@@@@@@...) After this broken line removing and google DNS (nameserver 8.8.8.8) adding everything started to work fine on my side.

serg06 commented 4 years ago

Faced same issue was not able to resolve github or ubuntu repos lets say from WSL - in my case it was corrupted /etc/resolv.conf (by default after installation it looked like something like that: @@@@@@@@@...) After this broken line removing and google DNS (nameserver 8.8.8.8) adding everything started to work fine on my side.

Same here! My PC blue screened then when I restarted it /etc/resolv.conf had had ^@^@^@^@^@^@...

What is the default value inside /etc/resolv.conf? I want to use my router for DNS resolution, just as I do on Windows.

Update: I added nameserver <router's local IP> and it worked.

Update 2: Found a permanent fix below: https://github.com/microsoft/WSL/issues/3268#issuecomment-628316415

yuezhizizhang commented 4 years ago

Same here. /etc/resolv.conf is ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

serg06 commented 4 years ago

To restore /etc/resolv.conf, add this line to the top of the file:

# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.

Then close all bash windows and open a fresh one. Open up /etc/resolv.conf and you should see auto-generated entries.

ibitoyeofd commented 4 years ago

Faced a similar issue - was not able to resolve GitHub from WSL. :~/code$ git clone https://github.com/IBM/adversarial-robustness-toolbox Cloning into 'adversarial-robustness-toolbox'... fatal: unable to access 'https://github.com/IBM/adversarial-robustness-toolbox/': Could not resolve host: github.com

My computer was connected to VPN. After disconnecting from the VPN, i was able to resolve the hosts. Seems strange but do not understand why that happened.

craigloewen-msft commented 1 year ago

Hi folks, we have put out a new update that aims to address networking issues in WSL. In your .wslconfig file you can set experimental.networkingMode=mirrored, as well as some other key settings that should improve your network compatibility! Please try them out and let us know what you think.

More info on this release and the changes can be found here in the blog post.

Please note: You need to be on a Windows Insiders version to use the new networking settings (Any channel of Windows Insiders will do, including release preview). If you see the "These are not supported" messages it means that your current Windows version doesn't have support, and you will need to upgrade. These features will eventually be coming to Windows 11 22H2.

Please use the megathread for more DNS discussion: #8365

detuur commented 1 year ago

@craigloewen-msft are these changes also coming to Windows 10 22H2?

OneBlue commented 5 months ago

VPN / connectivity Hi ! Please try the latest networking features that we've added in WSL. Those should greatly improve compatibility with VPN's.

If the issue still remains, please reopen this issue.

@craigloewen-msft are these changes also coming to Windows 10 22H2?

Unfortunately DNS tunnelling is only available on Windows 11 and will not come back to Windows 10.