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

Querying ${hostname}.local takes forever due to DNS server that is built into WSL #12080

Open
1 of 2 tasks
sigasigasiga opened this issue Sep 25, 2024 · 11 comments
Open
1 of 2 tasks
Assignees
Labels

Comments

@sigasigasiga
Copy link

sigasigasiga commented Sep 25, 2024

Windows Version

Microsoft Windows [Version 10.0.22631.4169]

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

Linux version 5.15.153.1-microsoft-standard-WSL2

Distro Version

Any, I guess. The bug reproduces on Ubuntu 23.04 and on openSUSE Tumbleweed 20240923

Other Software

on my openSUSE Tumbleweed machine:
avahi-daemon 0.8
libnss-mdns 0.15.1-1.5
systemd 256.5-1.1

Repro Steps

$ 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 10.255.255.254

$ time getent hosts ${hostname}.local
172.28.0.1      egor-bychin-pc.local

________________________________________________________
Executed in   10.02 secs      fish           external
   usr time    3.26 millis  177.00 micros    3.08 millis
   sys time    0.53 millis  530.00 micros    0.00 millis

However, if I change my DNS server in /etc/resolv.conf, then everything is super fast:

$ cat /etc/resolv.conf
nameserver 1.1.1.1

$ time getent hosts ${hostname}.local
172.28.0.1      egor-bychin-pc.local

________________________________________________________
Executed in   10.55 millis    fish           external
   usr time    1.31 millis   57.00 micros    1.26 millis
   sys time    0.21 millis  210.00 micros    0.00 millis

Expected Behavior

I get the results in 10 seconds

Actual Behavior

I get the results in 0.00001 seconds

Diagnostic Logs

No response

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.

@sigasigasiga
Copy link
Author

Copy link

Diagnostic information
Multiple log files found, using: https://github.com/user-attachments/files/17138533/WslNetworkingLogs-2024-09-26_00-58-02.zip
Detected appx version: 2.2.4.0
optional-components.txt not found

@CatalinFetoiu
Copy link
Collaborator

CatalinFetoiu commented Oct 5, 2024

hello. thanks for reporting the issue. can you please try either of the following 2 solutions documented at https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#resolve-local-names-in-wsl and let us know if those resolve the issue?

  1. keep using networkingMode=nat (as you are currently doing), but disable dnsTunneling
  2. use networkingMode=mirrored and do the additional configs from the link above - install libnss-mdns and configure /etc/nsswitch.conf (I see you already have libnss-mdns installed)

@sigasigasiga
Copy link
Author

@CatalinFetoiu thank you for your reply!

Setting networkingMode=mirrored didn't help at all.

However, by setting dnsTunneling=false I managed to get some huge boost -- now it takes whopping 1 second to complete my request!

But I must admit that 1 second is still quite slow comparing to the results I'm getting with using any custom DNS server (e.g. 1.1.1.1):

$ 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.28.0.1

$ time getent hosts ${hostname}.local
172.28.0.1      egor-bychin-pc.local

________________________________________________________
Executed in    1.05 secs      fish           external
   usr time    2.32 millis    0.00 micros    2.32 millis
   sys time    0.43 millis  435.00 micros    0.00 millis
$ cat /etc/resolv.conf
nameserver 1.1.1.1

$ time getent hosts ${hostname}.local
172.28.0.1      egor-bychin-pc.local

________________________________________________________
Executed in  116.05 millis    fish           external
   usr time    1.95 millis   89.00 micros    1.86 millis
   sys time    0.35 millis  355.00 micros    0.00 millis

I think the results may still be greatly improved by some changes on your side

@CatalinFetoiu
Copy link
Collaborator

CatalinFetoiu commented Oct 5, 2024

@sigasigasiga thanks for following up
regarding networkingMode=mirrored, sorry, I forgot to mention you need to be on a build 2.3.17 for this to work (we made some fixes so that mDNS can work in mirrored mode). Also, you don't need to disable dnsTunneling in this case (disabling it is needed only in NAT mode)

for the case where you see a 1 second delay, could you please collect new networking logs (WslNetworkingLogs) ?

@sigasigasiga
Copy link
Author

sigasigasiga commented Oct 7, 2024

@CatalinFetoiu


regarding networkingMode=mirrored, sorry, I forgot to mention you need to be on a build 2.3.17 for this to work (we made some fixes so that mDNS can work in mirrored mode).

I actually have a newer version of WSL

> wsl --version
WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4169

And the domain still resolves in 10 seconds with networkingMode=mirrored. Did you mean that I need to downgrade it to 2.3.17 for mirrored networking mode to fix the problem?


Also, you don't need to disable dnsTunneling in this case (disabling it is needed only in NAT mode)

Yes, I got that right from the start: I've done the first test with

[wsl2]
networkingMode=mirrored
#dnsTunneling=false

and the second one with

[wsl2]
#networkingMode=mirrored
dnsTunneling=false

for the case where you see a 1 second delay, could you please collect new networking logs (WslNetworkingLogs) ?

Okay, here's the logs collected from the machine with dnsTunneling=false set in .wslconfig. As in previous tests, the command I ran was getent hosts ${hostname}.local.

WslNetworkingLogs-2024-10-07_16-52-49.zip

Copy link

github-actions bot commented Oct 7, 2024

Diagnostic information
.wslconfig found
Detected appx version: 2.3.24.0
optional-components.txt not found

@CatalinFetoiu
Copy link
Collaborator

@sigasigasiga thanks for sending logs

sorry for the confusion about the WSL build number, I meant to say any build that is 2.3.17 or higher

could you please also collect networkings logs from the mirrored networking case? We should understand why resolution takes 10 seconds there

@sigasigasiga
Copy link
Author

Copy link

Diagnostic information
.wslconfig found
Detected appx version: 2.3.24.0
optional-components.txt not found

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

3 participants