Configure HA VM network options on boot

I run multiple VLANs at home, and expose 3 network interfaces to the Home Assistant VM. Whenever the VM boots, I need to disable mdns on 2 of the 3 interfaces in order to prevent Home Assistant from running into hostname discovery conflicts and filling the logs with errors.

Normally I console into the VM and perform this manually by running nmcli commands, but would like to have this done automatically when the device boots.

Any suggestions for how I might accomplish this would be appreciated.

I’m trying to think of some ways, but may I ask first, what nmcli command(s) are you using to disable mDNS?

I run this command against the secondary and tertiary interfaces:

nmcli connection modify <connection> connection.mdns resolve

Then restart the NetworkManager service

After scratching my head on various possibilities, most of them came to a dead end. About the only two possibilities that come to mind, both of which could be used with an automation running as a HA command_line switch and shell command:

  • ssh from HA Core to the HAOS root shell and execute the nmcli command. I have run something like this to my VM Host, but I have not actually tried this to the HAOS root shell, but I think it would be possible
  • HA Core doesn’t have nmcli, but it does have gdbus and the D-Bus can be used to query/set parameters to the NMCLI daemon. Here is an example. I have not worked through this nearly enough to say how to do this or even whether it will work … but just an idea.