Heya fellow coders/developers/networkers/Devops/...
I have an issue with an mDNS
/DNS-SD
setup in the context of WSL2 (Windows 10 2004 version)
I have a pretty simple setup at home with a main server and a Raspberry Pi, and I would like to activate DNS service discovery, thus allowing me to have a simple way to do automatic discovery of my server on my Raspberry PI.
Using a simple library like dnssd, or even broadcasting the right data myself, I manage to make it work easily when not using WSL2. However I have a requirement to make it work on WSL2 and this is where things get complicated.
As WSL2 is running on its own subnet, the broadcasting does not work anymore. Using mDNS on a subnet only works in this subnet. However Windows already reroute some of the broadcast traffic between the host and WSL.
This is testable easily : doing a simple Ping
from my server to the Avahi address of the Pi which relies on mDNS works.
On the left side of the screen you can see traffic captured by Wireshark on the host network interface and on the right side, you can see the traffic captured by Wireshark on the WSL network interface.
The first 3 lines are a simple ping : it is executed in the context of WSL, but the IP address that appears here - 172.28.192.1
- is not the IP address of the WSL client, it is the IP address of the internal DNS server of WSL. It is perfectly rerouted on the host as you can see on the right, with the IP address of the windows host: 192.168.0.39
However, the second query, which is executed by a script, has the WSL source IP (172.28.204.42
) and this one is not rerouted on the host.
My network knowledge is very limited and I do not understand how this work, and how I could make WSL route my own mDNS queries on the host. A wild guess would be that it has something to do with iptables, but that is as far as I go.
If anyone has a clue on why it works on the DNS server source address and not when I perform it myself it would help me a lot !