WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Can't access local DNS entries in WSL, why?

Open piradata opened this issue 8 months ago • 13 comments

Windows Version

Microsoft Windows [versão 10.0.26120.3941]

WSL Version

2.5.7.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

Linux version 6.6.87.1-microsoft-standard-WSL2

Distro Version

Ubuntu 24.04

Other Software

No response

Repro Steps

Image

Expected Behavior

should work, as i am using it in networkingMode=mirrored

Actual Behavior

does not work

Diagnostic Logs

No response

piradata avatar Apr 26 '25 23:04 piradata

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'.

github-actions[bot] avatar Apr 26 '25 23:04 github-actions[bot]

/question

piradata avatar Apr 27 '25 18:04 piradata

Diagnostic information
Found '/question', adding tag 'question'

github-actions[bot] avatar Apr 27 '25 18:04 github-actions[bot]

Thank you for reporting this @piradata. Can you share a bit more about how that DNS record is configured ?

OneBlue avatar Apr 28 '25 19:04 OneBlue

I'm experiencing a similar problem. On my machine, I'm running

Edition	Windows 11 Enterprise
Version	24H2
Installed on	‎4/‎28/‎2025
OS build	26100.3915
Experience	Windows Feature Experience Pack 1000.26100.83.0

with

WSL version: 2.4.13.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5716
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.3915

and .wslconfig containing

[wsl2]
networkingMode=mirrored

On Windows' cmd, I observe

>ping -n 5 github.com

Pinging github.com [140.82.121.4] with 32 bytes of data:
Reply from 140.82.121.4: bytes=32 time=42ms TTL=52
Reply from 140.82.121.4: bytes=32 time=25ms TTL=52
Reply from 140.82.121.4: bytes=32 time=48ms TTL=52
Reply from 140.82.121.4: bytes=32 time=28ms TTL=52
Reply from 140.82.121.4: bytes=32 time=26ms TTL=52

Ping statistics for 140.82.121.4:
    Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 25ms, Maximum = 48ms, Average = 33ms

but I observe on WSL2 running Ubuntu 24.04

$ ping -n 5 github.com
ping: github.com: Temporary failure in name resolution

I'm using Wi-Fi at the moment. The network is configured as

ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : KOL22104
   Primary Dns Suffix  . . . . . . . : gesis.intra
   Node Type . . . . . . . . . . . . : Peer-Peer
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : gesis.intra

Other adapter Connect Tunnel:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : gesis.intra
   Description . . . . . . . . . . . : SonicWall VPN Adapter
   Physical Address. . . . . . . . . : 13-AD-0C-91-B9-5F
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : gesis.intra
   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (13) I219-V
   Physical Address. . . . . . . . . : 88-A4-C2-53-0D-55
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 1:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
   Physical Address. . . . . . . . . : BC-09-1B-08-F6-A7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #2
   Physical Address. . . . . . . . . : BE-09-1B-08-F6-A6
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Mobile Broadband adapter Cellular:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Generic Mobile Broadband Adapter
   Physical Address. . . . . . . . . : B4-9D-8F-4B-59-5C
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : fritz.box
   Description . . . . . . . . . . . : Intel(R) Wi-Fi 6 AX201 160MHz
   Physical Address. . . . . . . . . : BC-09-1B-08-F6-A6
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.178.29(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Wednesday, April 30, 2025 10:31:13 AM
   Lease Expires . . . . . . . . . . : Saturday, May 10, 2025 10:31:13 AM
   Default Gateway . . . . . . . . . : 192.168.178.1
   DHCP Server . . . . . . . . . . . : 192.168.178.1
   DNS Servers . . . . . . . . . . . : 192.168.178.1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Thanks for any help.

rgaiacs avatar Apr 30 '25 08:04 rgaiacs

Thank you for reporting this @piradata. Can you share a bit more about how that DNS record is configured ?

It is the local dns that the raspberry pi creates automatically when it is connected on the local network, discovered by some implementarion of mDns as bonjour.

".local" domain has been officially reserved as a Special-Use Domain Name (SUDN) specifically for the purpose of internal network usage. It will never be configured as a FQDN and as such your custom local names will never conflict with existing external addresses

The raspberrypi.local address works due to a protocol called mDNS (Multicast DNS), which allows devices on the same local network to resolve each other's hostnames without needing a central DNS server. Here's how it works on a Raspberry Pi:

  1. mDNS and Avahi

Raspberry Pi OS comes with a service called Avahi, which is a Linux implementation of the Apple Bonjour/mDNSResponder.

When the Pi boots up, Avahi advertises its hostname (default is raspberrypi) on the local network via mDNS.

This makes the hostname accessible as raspberrypi.local to other devices on the same network that also support mDNS (like macOS, most Linux distros, or Windows with extra software).

  1. What Happens Internally

The Pi sends a multicast DNS packet to the IP address 224.0.0.251 (IPv4) or ff02::fb (IPv6), on port 5353, announcing "Hey, raspberrypi.local is at this IP."

Other mDNS-capable devices listen to this multicast address and learn that raspberrypi.local maps to that IP.

piradata avatar Apr 30 '25 19:04 piradata

if you want me to run any test commands just say, and I can do the testing, just dont know what to look for

all beworking vesides that works fine, dns resolution is ok besides local mDns entryes

piradata avatar Apr 30 '25 19:04 piradata

Thank you for the context @piradata. @CatalinFetoiu : Do we support mDns records in with mirrored networking ?

OneBlue avatar Apr 30 '25 22:04 OneBlue

@piradata @OneBlue in order to have mDNS working in mirrored mode, please refer to the following doc page, the section "networkingMode set to Mirrored" https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#resolve-local-names-in-wsl

let us know if you have any questions or run into issues

thanks!

CatalinFetoiu avatar May 02 '25 02:05 CatalinFetoiu

Thanks @CatalinFetoiu , it worked! But there is 2 things that are strange. the first one is that it is extremely slow to start pinging .local domains, while .com or others domains not local are almost instant. is that normal?

The other strange thing is that nslookup does not catch this dns route :(

Recorded a video to show it below:

https://github.com/user-attachments/assets/e7cacc56-dd07-42d3-8a83-2526a1219a0f

piradata avatar May 04 '25 19:05 piradata

@piradata thanks for following up - happy to know the doc instructions helped!

regarding nslookup, my understanding is that it does not use mdns and does not know how to resolve .local names

regarding the slow resolution part, that sounds similar to another report we got: https://github.com/microsoft/WSL/issues/12080

CatalinFetoiu avatar May 05 '25 23:05 CatalinFetoiu

humm, saw it now, just commented there, and i fixed it by disabling the dns tunnelling :)

Thanks!

piradata avatar May 08 '25 04:05 piradata

@CatalinFetoiu actually, i noted something, here is a test with mirror mode and tunnel on (when there is a fixed 10 seconds time, every time, to resolve the dns, as if it is a fixed timeout somewhere)

[wsl2]
networkingMode=mirrored
dnsTunneling=true
swap=10GB

Image

and here is a test with mirror mode and tunnel off (google.com does not resolve anymore)

[wsl2]
networkingMode=mirrored
dnsTunneling=false
swap=10GB

Image

as it is stated here, all should work with dns tunnel disable, no? but it makes external dns resolution fail..

Image

piradata avatar May 17 '25 23:05 piradata