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

DNS broken - /mnt/wsl is empty - resolv.conf missing #11928

Closed
1 of 2 tasks
torgeros opened this issue Aug 16, 2024 · 19 comments
Closed
1 of 2 tasks

DNS broken - /mnt/wsl is empty - resolv.conf missing #11928

torgeros opened this issue Aug 16, 2024 · 19 comments

Comments

@torgeros
Copy link

torgeros commented Aug 16, 2024

NOTE: This might be a reopen of #11036

Windows Version

Microsoft Windows [Version 10.0.22631.3880]

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.153.1-microsoft-standard-WSL2

Distro Version

Ubuntu 22.04 LTS

Other Software

Docker is installed (WSL-based backend)

Repro Steps

I don't know

Expected Behavior

accessing the internet being possible inside wsl

Actual Behavior

Every hostname- / url-based network request fails with Temporary failure in name resolution. The internet guided me towards the /etc/resolv.conf file. This file, however, is just a symlink to /mnt/wsl/resolv.conf which, from what I have read, should be automatically generated every time WSL boots. However, the /mnt/wsl directory is completely empty. When I create a file inside /mnt/wsl, it is deleted after a WSL reboot.

And obviously, with /etc/wsl/resolv.conf not existing, my DNS cannot resolve anything.

WSL used to work previously, I do not know when exactly it stopped working.

Diagnostic Logs

/etc/wsl.conf:


[boot]
systemd=true
@torgeros torgeros changed the title DNS broken - resolv.conf is missing DNS broken - /mnt/wsl is empty - resolv.conf missing Aug 16, 2024
Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@torgeros
Copy link
Author

This is a duplicate of #11693.

@torgeros
Copy link
Author

As it turned out in #11693 (comment), these issues are not the same. I am completely missing my wsl config whereas theirs is at least present...

@torgeros torgeros reopened this Aug 19, 2024
@torgeros
Copy link
Author

Fyi, I cannot take the logs because I do not have administrator-level access.

@OneBlue
Copy link
Collaborator

OneBlue commented Aug 19, 2024

Unfortunately logs are required for us to being able to root cause issue. I'll close for now but feel free to reopen if you can collect logs.

@OneBlue OneBlue closed this as completed Aug 19, 2024
@kohlerdominik
Copy link

kohlerdominik commented Sep 9, 2024

Hi @torgeros @OneBlue

I have this issue and already posted in #11693.
Here are my logs: https://github.com/user-attachments/files/15840532/WslLogs-2024-06-14_17-43-54.zip
Please reopen.

@torgeros Do you have a LAN having a networkadress in the 172.x.x.x. range?

@OneBlue In my case this issue appeared after a couple of days having my new notebook when I connected it to the company network 172.25.1.0/16.
I think the problem originates from Hyper-V assigning a random 172.x.x.x-network for the WSL environment. So in that case, it Auto-Assigned some 172.25.?.0/20 network. Once I joined an overlapping network, it crashed. My network /mnt/wsl/resolv.conf is missing ever since. Hyper-V recovered and choose a new IP-Subnet (172.24.192.0/20 now), but it seems that WSL missed something and now can't generate the resolv.conf.

@torgeros
Copy link
Author

torgeros commented Sep 9, 2024

@torgeros Do you have a LAN having a networkadress in the 172.x.x.x. range?

The only thing in my ipconfig with a 172 address is the WSL adapter.
It could be possibole, however, that some docker network had static ip stuff somewhere in that range configured...

@oKazuhiro
Copy link

Hi @kohlerdominik the issue you have seems very similar to the issue I am having.

I am experiencing a similar issue where WSL is unable to generate and link the resolve.conf file. My host's Ethernet adapter is using a static IP in range 172.x.x.x. I actually have Hyper-V disabled, but Virtual Machine Platform is enabled so that I can use WSL2.

I was using mirrored networking mode, but switched back to the default NAT networking mode which fixed the connectivity issues, but I need to use mirrored networking mode due to some issues with port forwarding.

@kohlerdominik
Copy link

Hi @oKazuhiro

Can you check wether /mnt/wsl/resolv.conf exists in your WSL-Distro?
grafik

@oKazuhiro
Copy link

Hi @oKazuhiro

Can you check wether /mnt/wsl/resolv.conf exists in your WSL-Distro? grafik

The symbolic link does exist at /etc/resolv.conf, but the file it links to in /mnt/wsl/resolv.conf is missing.

@torgeros torgeros reopened this Sep 19, 2024
@kohlerdominik
Copy link

kohlerdominik commented Sep 19, 2024

@torgeros Thanks.

How can we help with fixing the issue? So it seems that we broke the generation of the resolv.conf, presumably by forcing Hyper-V to switch to another IP-address for its virtual network (Ethernet-Adapter vEthernet (Default Switch)), because the one it choose initialize was taken by a physical network adapter.

@oKazuhiro
Copy link

Found a solution that worked for me.

I ended up having to enable IPv6 in the registry.

This issue helped me come to this solution: #11002

  1. Open regedit.
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters.
  3. Modify DisabledComponents to 20 (Hex) to prefer IPv4 while keeping IPv6 enabled. or 00 (Hex) to fully enable IPv6.
  4. Restart the system.

@kohlerdominik
Copy link

@oKazuhiro So with your fix, the /mnt/wsl/resolv.conf is back again? Unfortunatelly, for me it didn't do anything...

@torgeros
Copy link
Author

torgeros commented Sep 23, 2024

The DisabledComponents key does not even exist in my registry.

The resolv.conf generation, however, seem to be permanently broken because across system reboots, even without any networks connected, it does not generate that file.

@torgeros
Copy link
Author

I was able to solve mine by setting

[wsl2]
dnsTunneling=false

in %UserProfile%\.wslconfig.

@kohlerdominik
Copy link

kohlerdominik commented Oct 2, 2024

I was able to solve mine by setting

[wsl2]
dnsTunneling=false

in %UserProfile%\.wslconfig.

Woulnd't that bypass host entries on the Windows instance? Meaning, this is more a bandaid than a solution?

And is your /mnt/wsl/resolv.conf back with dnsTunneling disabled?

@torgeros
Copy link
Author

torgeros commented Oct 2, 2024

@kohlerdominik Basically, per the docs, dnsTunneling specifies the opposite of what it sounds like.
With dnsTunneling=true, dns requests are processed inside WSL by, and I am quoting here, "a virtualization feature" which is not further specified.
However, with dnsTunneling=false, dns requests are actually passed through as networking packets and resolved on the windows host.

And yes, my /mnt/wsl/resolv.conf is back with the following content:

# 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.0.1

This matches with 172.19.0.1 as my windows host IP (ip route show | grep -i default | awk '{ print $3}')

@kohlerdominik
Copy link

@torgeros Thank you very much, this indeed fixed it for me as well. Still no idea how it broke for dnsTunneling=true, though...

@ivarprudnikov
Copy link
Member

Just had this issue of resolv.conf missing and the symlink pointing to a non existent resolv.conf in wsl dir. Rebooting wsl did not generate a new resolv.conf. My wslconfig had:

$ cat /etc/wsl.conf
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config#example-wslconf-file
[boot]
systemd=true
command = ntpdate time.windows.com; service cron start; service docker start'

Added explicit params to config but that made no difference:

[network]
generateHosts = true
generateResolvConf = true

I created .wslconfig in windows as there was none (read docs about it) and set:

[wsl2]
debugConsole=true

Then:

  • restarted wsl with wsl.exe --shutdown
  • after starting debug window appeared but it got stuck on login and could not proceed.
  • updated Windows and restarted it
  • started wsl again and this time the debug window was not stuck on login and wsl instance successfully booted
  • resolv.conf was generated
$ ls -la /etc/resolv.conf
/etc/resolv.conf -> /mnt/wsl/resolv.conf
$ ls /mnt/wsl/resolv.conf
/mnt/wsl/resolv.conf
$ cat /mnt/wsl/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 10.255.255.254

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

No branches or pull requests

5 participants