Avahi resolution while in routed mode

Hello,

When using a routed mode networking connection for a container, how can we take advantage of the avahi daemon for resolving local network hosts?

I usually install libnss-mdns on the container, and that works, however in the routed more, it can resolve host from container, container from host, but not other ips in the local network, but outside host.

In docker, there is a trick to do it with:

-v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket

so the docker container will use avahi-daemon of the host. Is there any way we can do similar in LXD?

Here is the profile I am using:

config:
raw.idmap: “both 1000 1000”
user.user-data: |
#cloud-config
package_update: yes
package_upgrade: yes
packages:
- libnss-mdns
user.network-config: |
version: 2
ethernets:
eth0:
addresses:
- 10.10.10.200/32
nameservers:
addresses:
- 8.8.8.8
search: []
routes:
- to: 0.0.0.0/0
via: 169.254.0.1
on-link: true
description: routed
devices:
eth0:
ipv4.address: 10.10.10.200
name: eth0
nictype: routed
parent: wlx74da38dc6b89
type: nic
root:
path: /
pool: default
type: disk
name: routed

Best Regards,
C.

The routed NIC mode, by design, does not allow the container’s NIC to join the parent network at layer 2, and only at layer 3 (routed).

This is so that the container cannot claim IPs it is not assigned by sending fake ARP/NDP packets.

So broadcast will not work.

As for multicast, I am not so familiar with it, but certainly it will not work “out of the box” as the container’s NIC is not part of the parent network’s layer 2.

It may be possible to have the LXD host work as a multicast router, but I’m afraid that is outside of my knowledge whether that is possible or what steps are involved.

Perhaps there is such as a thing as an MDNS repeater that could be run on the LXD host to receive DNS queries from the container and then relay them onto the parent network?