WSL2, DNS tunneling, and .local names
Just copying the text of a post I made to Reddit. Long story short: if you want .local domain names to work in WSL2, you may have to turn off DNS tunneling.
Query
I’ve got several Linux boxes on my LAN running avahi-daemon. I can connect to machine.local fine on most of my LAN, including my Windows desktop in a web browser or DOS shell. However, my WSL2 system cannot connect to machine.local, it seems unable to resolve mDNS at all.
I tried finding an answer and found several years’ worth of advice, some conflicting. The root cause seems to be WSL2’s complicated networking setup interfering with multicast. Unfortunately I don’t really understand WSL2’s network setup. Is there some easy way to get mDNS resolving working?
Comment I wrote with solution
Setting dnsTunneling to false makes .local names work. I had to restart the WSL2 system as well.
DNS tunneling is described here and the configuration file is described here. There’s also this bug report on GitHub.
Before the change my WSL2 had 10.255.255.254 as the nameserver in the resolv.conf, now it has 172.31.0.1. DNS tunneling is relatively new (from Windows 11 22H2) and “is aimed to improve compatibility with VPNs, and other complex networking set ups”. So maybe turning it off causes other problems. But basic DNS and Tailscale’s Magic DNS are both still working for me and now .local names work too, so I’m happy.