Avahi in a virtual machine running ubuntu server

Hi,

i would like to use avahi in a virtual machine runnning on truenas scale (Dragonfish-24.04.0). I installed ubuntu server and in ubuntu ahvahi-daemon and cups and avahi-utils.

The virtual machine has a seperate ip. 172.16.1.141 interface ens3
Truenas has 172.16.1.151 interface eno1
ens3 is somehow shared with eno1 (bridged / virtual switch ???)

hostname of vm is ubis.
hostname of truenas is truenas.

In the vm:

● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-04-29 16:03:08 UTC; 24min ago
TriggeredBy: ● avahi-daemon.socket
   Main PID: 5675 (avahi-daemon)
     Status: "avahi-daemon 0.8 starting up."
      Tasks: 2 (limit: 4552)
     Memory: 816.0K
        CPU: 33ms
     CGroup: /system.slice/avahi-daemon.service
             ├─5675 "avahi-daemon: running [ubis.local]"
             └─5676 "avahi-daemon: chroot helper"

Apr 29 16:03:08 ubis avahi-daemon[5675]: Joining mDNS multicast group on interface lo.IPv6 with address ::1.
Apr 29 16:03:08 ubis avahi-daemon[5675]: New relevant interface lo.IPv6 for mDNS.
Apr 29 16:03:08 ubis avahi-daemon[5675]: Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
Apr 29 16:03:08 ubis avahi-daemon[5675]: New relevant interface lo.IPv4 for mDNS.
Apr 29 16:03:08 ubis avahi-daemon[5675]: Network interface enumeration completed.
Apr 29 16:03:08 ubis avahi-daemon[5675]: Registering new address record for fe80::2a0:98ff:fe0e:eda5 on ens3.*.
Apr 29 16:03:08 ubis avahi-daemon[5675]: Registering new address record for 172.16.1.141 on ens3.IPv4.
Apr 29 16:03:08 ubis avahi-daemon[5675]: Registering new address record for ::1 on lo.*.
Apr 29 16:03:08 ubis avahi-daemon[5675]: Registering new address record for 127.0.0.1 on lo.IPv4.
Apr 29 16:03:09 ubis avahi-daemon[5675]: Server startup complete. Host name is ubis.local. Local service cookie is 1876491150.

ping ubis.local on cli of truenas shell states that name is not known

ping truenas.local on windows client works
pring ubis.local on windows dows not work

avahi-browse -a in vm runs but does not show anything, does not return to cli. has to be stopped with crtl+c

avahi-browse -a on a ubuntu client (not a vm) shows numerous entries.

It seems that truenas does not let the mdns messages pass to the vm. Nor is the hostname of the vm known to the other clients on the network.

checkbox in network settings of truienas for mdns is active:

How can i configure truenas and/or the vm, so that ahavi is working for the vm?

My mainboard has 4 nics (shown in truenas as eno1-4). Would it help to use e.g. eno2 for the vm somehow?

Best regards,
Nestor

ubis.local on Windows should work. ubis.local on TrueNAS shell won’t because there is no mDNS client in TrueNAS.

As for why it doesn’t work in Windows, if your TrueNAS was CORE and not SCALE I would immediately point you at the fact that you must manually create the bridge interface before launching the VM and move the IP address from the physical IF to the bridge or multicast will simply not work.

I do not know if this is the case for SCALE, too, someone else will have to step in.

Thank you, in the meantime I tried to attach the nic of the vm to eno2. But that did not change anything.

eno1 is 172.16.1.151
and
eno2 is 172.16.154
for truenas.

ens3 in the vm is still 172.16.141.

regarding avahi nothing changed.

so eno2 is now also used by truenas. I expected that eno2 will be used directly by the vm. But there seems to be an administrative layer managed by truenas as with eno1. Consequently nothing changed regarding avahi.

I will try to learn more about the bridge mentioned by you and report here.

Best regards,
Nestor

Setting up a bridge is explained here:

I put eno2 as member (what does that mean??? does that imply that there should be more members???) to br1.

Then I tried attach br1 as nic to the vm:

Then started the vm and the following error message appeared:

# error CallError

[EFAULT] VM will not start as NIC Device: br1 device(s) are not available.``` 

Obviously I did not understand the bridge concept correctly.

This youtube tutorial

finally helped.

The video is difficult to understand acoustically. However, if you concentrate you can gather how to set up a bridge in truenas scale and connect it to the vm.

I even managed to use eno2 for the bridge. So truenas itself is still reachable over eno1.

What confused me initially is that the IP you assign to the bridge is not the IP you use to ssh into the vm. In my case i assigned the ip 172.16.1.174 to the bridge in the network settings. And the vm has the ip 172.16.1.141. I figured out that the vm obtained the ip via dhcp from my router (in the ip leases list).

However, it works. And if you then enter e.g.: sudo avahi-browse -a you get a nice list of the services available in the local network, which are made known via bonjour/avahi. In my case, this also includes the printers made known by my CUPS print server.

So far so good.