My mdns address myhost.local mistakenly bound to Docker virtual network, not my wifi network

Solution 1:

There are multiple name resolution mechanisms active here by default:

  • /etc/hosts
  • mdns
  • dns

This is the default order, and mdns usually tries to resolve *.local

But also consider that this is the case separately for two machines -- the local and the remote machine.

So, if you want myhost.local to resolve to a specific interface without disabling mdns on other interfaces, you should be able to just put an override in /etc/hosts. However, this only affects the local machine.

Remote machines will resolve myhost.local with whatever mdns broadcasts they hear. So if they are on your docker network, and your lan (as your local machine would be), they would get all those addresses from mdns. If they're only on one of those networks, they should see only the address that corresponds to that network.

So perhaps the solution is not to change configuration, but change what host you are using to ask the question.

Solution 2:

Reading the man page for the avahi daemon conf file (/etc/avahi/avahi-daemon.conf) it looks like you can specify interfaces that you explicitly want to deny:

deny-interfaces= Set a comma seperated list of network interfaces that should be ignored by avahi-daemon. Other not specified interfaces will be used, unless allow-interfaces is set. This option takes precedence over deny-interfaces.

So maybe try adding the line "deny-interfaces=docker0" to that file (always backup the original!), and then reloading with "avahi-daemon --reload". Change "docker0" to whatever your docker interface is called, though I think that's the default.

https://linux.die.net/man/5/avahi-daemon.conf

http://manpages.ubuntu.com/manpages/bionic/man8/avahi-daemon.8.html