The WSL2 Hyper-V network switch does not act as a multicast bridge. By default, the switch creates an internal network. Multicast packets are only delivered to systems connected to the internal network and not to anything beyond it. More information about Hyper-V network types can be found in this Nakivo blog post.
In your first case, the ping triggers a regular DNS lookup that goes to the resolver -- the Windows host. The Windows host then performs an mDNS lookup on both its external and internal networks. Your packet dump shows the internal lookup, but note that nothing responds to it. The response comes via the external network, and the ping gets its response via regular DNS. In your second case, you perform only an mDNS lookup. That lookup receives no response, because it only goes to the internal network. For proof that mDNS lookups work on the internal network, do a lookup for the Windows host's local address (MACHINE.local). It will work, because the Windows host is on the internal network and can respond.
The good news is you can change the WSL network type.
- Hit your Windows key and type "Hyper-V Manager"
- Right-click on the app and choose "Run as administrator"
- In the manager, find your machine under "Hyper-V Manager" and click on it
- In the Actions area, click on "Virtual Switch Manager..."
- Find the WSL switch and click on it
- Change the connection type to "External network"
- Click OK
After doing this, restart WSL:
> wsl --shutdown
> wsl -t <distribution-name>
> wsl --distribution <distribution-name>
Once restarted, your guest's network will be broken. You will need to add an IP address and route from your external network using ip addr add
and ip route
or something similar. Your distribution is almost certainly going to try to setup its network for the default WSL switch every time it starts, so you may need to setup configurations to add this external network address in the future. As an example, Ubuntu 20.04 always adds a dynamic address on the internal network, regardless of the switch configuration.
Making the change to the network switch type will likely break other uses of WSL2 (e.g. Docker Desktop) for the same reason. Windows re-creates the Hyper-V network switch every time it reboots, so your change will only last as long as your system stays up.