WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL2 DNS stops working

Open jordansissel opened this issue 7 years ago • 297 comments

Please fill out the below information:

  • Your Windows build number: (Type ver at a Windows Command Prompt)

Microsoft Windows [Version 10.0.18932.1000]

  • What you're doing and what's happening:
> bash
% host google.com
;; connection timed out; no servers could be reached
  • What's wrong / what should be happening instead: DNS resolution should work

/etc/resolv.conf:

% 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.19.224.1

To my knowledge, I didn't change anything. This has happened a few times, and rebooting fixes it. Sometimes just doing wsl --shutdown is sufficient to fix it. It correlates with my workstation going to sleep and resuming later with DNS in WSL2 not working.

jordansissel avatar Jul 08 '19 16:07 jordansissel

Whatever provides the internal WSL2 dns seems busted, but other dns servers are successful:

% 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.19.224.1

% host google.com 172.19.224.1
;; connection timed out; no servers could be reached

% host -t A google.com 1.1.1.1
Using domain server:
Name: 1.1.1.1
Address: 1.1.1.1#53
Aliases:

google.com has address 216.58.194.174

jordansissel avatar Jul 08 '19 18:07 jordansissel

@jordansissel This started happening to me yesterday, but it seems my whole network is busted:

$ host -t A google.com 1.1.1.1
;; connection timed out; no servers could be reached
$ ping 8.8.8.8
connect: Network is unreachable

Running with AV and Firewall disabled.

EDIT: I disabled, restarted, and re-enabled the WSL and Virtual Machine Windows Features and it looks to work now.

lkuich avatar Jul 08 '19 20:07 lkuich

I ran into this same issue; resolved for now after removing etc/resolve.conf and resetting the entire dns config via the resolvconf package, pointing to cloudflare's 1.1.1.1.

develleoper avatar Jul 09 '19 22:07 develleoper

Maybe it is related to this: #4275

heamaral avatar Jul 10 '19 17:07 heamaral

Using build: 18932.1000: I ran into this issue on Ubuntu also. Sometimes rebooting windows host and executing wsl --shutdown works. Will look into it further as it occurs and check back on solutions.

bmpertierra avatar Jul 11 '19 18:07 bmpertierra

I am seeing this same DNS behavior on Build 18941. The local DNS server is not responding but I can route out to the internet and everything works fine once I set a manual resolv.conf. Using both the official Kali and Ubuntu distros in the store, converted to WSL 2. I have no other Hyper-V VMs.

Ifconfig:

bond0: flags=5122<BROADCAST,MASTER,MULTICAST> mtu 1500 ether 0a:b1:11:d2:aa:66 txqueuelen 1000 (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

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.18.201.80 netmask 255.255.0.0 broadcast 172.18.255.255 inet6 fe80::215:5dff:fe9a:1fe3 prefixlen 64 scopeid 0x20 ether 00:15:5d:9a:1f:e3 txqueuelen 1000 (Ethernet) RX packets 11 bytes 1507 (1.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 1232 (1.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 8 bytes 560 (560.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 8 bytes 560 (560.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

sit0: flags=128 mtu 1480 sit txqueuelen 1000 (IPv6-in-IPv4) 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

astamos avatar Jul 23 '19 15:07 astamos

Facing the same issue on 18956. manually setting resolv.conf is a temporary solution. adding generateResolvConf to false did not affect anything. What's with that ip address (one starting with 172) though? have never seen it before

mahsoommoosa42 avatar Aug 15 '19 19:08 mahsoommoosa42

Facing the same issue on 18956. Git and Ping does not work.

mahsoommoosa42 avatar Aug 15 '19 19:08 mahsoommoosa42

My workaround:

  1. Create a file: /etc/wsl.conf.
  2. Put the following lines in the file
[network]
generateResolvConf = false
  1. In a cmd window, run wsl --shutdown
  2. Restart WSL2
  3. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
  4. Put the following lines in the file
nameserver 8.8.8.8
  1. Repeat step 3 and 4. You will see git working fine now.

non-static avatar Aug 17 '19 03:08 non-static

Yeah. I did the same. I suppose it's occuring due to the modifications to network settings with the last fast ring update.

Get Outlook for Androidhttps://aka.ms/ghei36


From: NonStatic [email protected] Sent: Saturday, August 17, 2019 9:09:55 AM To: microsoft/WSL [email protected] Cc: mahsoommoosa42 [email protected]; Comment [email protected] Subject: Re: [microsoft/WSL] WSL2 DNS stops working (#4285)

My workaround:

  1. Create a file: /etc/wsl.conf.
  2. Put the following lines in the file

[network] generateResolvConf = false

  1. In a cmd window, run wsl --shutdown
  2. Restart WSL2
  3. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
  4. Put the following lines in the file

nameserver 8.8.8.8

  1. Repeat step 3 and 4. You will see git working fine now.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FWSL%2Fissues%2F4285%3Femail_source%3Dnotifications%26email_token%3DAFA4ITLUCJ7RBWMFDIP3MHLQE5XIXA5CNFSM4H65IQMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QCPPI%23issuecomment-522201021&data=02%7C01%7C%7C73660638a70d4dbc6c4f08d722c49219%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637016099969731395&sdata=6rg9%2FiwAZkJoOhwhu6sHElqoJptYoS19AbuYTY5flPw%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFA4ITMQRWJZKXU26K6BC33QE5XIXANCNFSM4H65IQMA&data=02%7C01%7C%7C73660638a70d4dbc6c4f08d722c49219%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637016099969741400&sdata=ufzaqjmQaVAOOmGeoirghbUOw9ZddYre3JAnJcprh5k%3D&reserved=0.

mahsoommoosa42 avatar Aug 17 '19 03:08 mahsoommoosa42

@Klein-Hu : tried your workaround, followed your steps, but it doesn't seem to be working for me.

My /etc/resolv.conf file is getting wiped out every time I relaunch wsl2 :-/

nonbeing avatar Sep 11 '19 09:09 nonbeing

Did you enter 'wsl --shutdown' into the cmd?


From: ambar [email protected] Sent: Wednesday, September 11, 2019 2:36 PM To: microsoft/WSL [email protected] Cc: mahsoommoosa42 [email protected]; Comment [email protected] Subject: Re: [microsoft/WSL] WSL2 DNS stops working (#4285)

@Klein-Huhttps://github.com/Klein-Hu : tried your workaround, followed your steps, but it doesn't seem to be working for me.

My /etc/resolv.conf file is getting wiped out every time I relaunch wsl2 :-/

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/WSL/issues/4285?email_source=notifications&email_token=AFA4ITKHNAZWNB7F7W6376LQJCYK7A5CNFSM4H65IQMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6NZ27Y#issuecomment-530292095, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFA4ITLPNO6V63C5UXARNC3QJCYK7ANCNFSM4H65IQMA.

mahsoommoosa42 avatar Sep 11 '19 14:09 mahsoommoosa42

Yes, I did.

nonbeing avatar Sep 11 '19 17:09 nonbeing

I'm not on Insiders anymore. So, I'm not sure if anything has changed in between.


From: ambar [email protected] Sent: Wednesday, September 11, 2019 11:01 PM To: microsoft/WSL [email protected] Cc: mahsoommoosa42 [email protected]; Comment [email protected] Subject: Re: [microsoft/WSL] WSL2 DNS stops working (#4285)

Yes, I did.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/WSL/issues/4285?email_source=notifications&email_token=AFA4ITIBLVEDLIBFTQUXDVLQJETQ3A5CNFSM4H65IQMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6PIQ6A#issuecomment-530483320, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFA4ITOQIJFP2RJ6C5KJ6TTQJETQ3ANCNFSM4H65IQMA.

mahsoommoosa42 avatar Sep 11 '19 17:09 mahsoommoosa42

@nonbeing make sure resolv.conf is a file and not a link

ls -la /etc/resolv.conf
-rw-r--r-- 1 root root 185 Sep 11 16:32 /etc/resolv.conf

onomatopellan avatar Sep 11 '19 22:09 onomatopellan

My workaround:

  1. Create a file: /etc/wsl.conf.
  2. Put the following lines in the file
[network]
generateResolvConf = false
  1. In a cmd window, run wsl --shutdown
  2. Restart WSL2
  3. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
  4. Put the following lines in the file
nameserver 8.8.8.8
  1. Repeat step 3 and 4. You will see git working fine now.

wsl --shutdown doesn't seem to work for me wslconfig.exe /terminate Ubuntu does

VictorGaiva avatar Sep 19 '19 04:09 VictorGaiva

Running insider 10.0.18980.1, kernel 4.19..67 Seems as if the dns resolver running on 172 is single threaded? Request that timeout seem to block.

h0tw1r3 avatar Sep 19 '19 06:09 h0tw1r3

Just started seeing this today after an update as well

Microsoft Windows [Version 10.0.18980.1]

Rhahkeem avatar Sep 21 '19 11:09 Rhahkeem

I made a gist with @Klein-Hu 's instructions. They worked like a charm for me.

Fix DNS resolution in WSL2

coltenkrauter avatar Oct 17 '19 14:10 coltenkrauter

For anyone seeing this, the "fixes" proposed are merely a workaround to the problem. In situations where internal/private DNS servers (eg. corporate or home network), DNS will not resolve as expected.

I consider this a critical bug.

h0tw1r3 avatar Oct 21 '19 16:10 h0tw1r3