mDNS and VLAN woes

Trying to set up an ESP32.
My ESP never appears online in ESPHome Device Compiler. I created a .bin and uploaded it manually. ESP boots and connects to wifi (I can access its web ui, I can add it to HA using ip which i have fixed from DHCP server).

How do I make it appear online in ESPHome Device Compiler?

“Downloading logs” seems to result in:

INFO ESPHome 2024.11.3
INFO Reading configuration /config/esphome/kaminaringi-termostaat.yaml...
INFO Starting log output from kaminaringi-termostaat.local using esphome API
WARNING Can't connect to ESPHome API for kaminaringi-termostaat.local: Error resolving IP address: [Errno -5] No address associated with hostname (APIConnectionError)

It also does not seem to resolve from Home Assistant command line:

[core-ssh ~]$ ping kaminaringi-termostaat.local
ping: bad address 'kaminaringi-termostaat.local'

Yes, it is in a different VLAN. However, I am using an mDNS repeater. kaminaringi-termostaat.local resolves perfectly well in my laptop which is at the moment in the same VLAN as HA. It also shows up few seconds after booting in an mDNS app called “Discovery”.

Screenshot 2024-12-11 at 21.24.43

Does .local resolve in your network?

.local is special-use domain for mDNS, I am not sure what you mean by “does it resolve in your network”.

As I said, I can resolve it in my laptop but not in HA

In the wifi section config, set the devices static IP or you can configure use_address.

Setup multicast forwarding so your multicast traffic is broadcasted to the vlans you want.

Can you be more specific? What/from/to which ports does the ESPhome send multicast? UDP?

Sure, I’ll be very specific. Read up on how multicast works, read up on what vlans are.

You’re sending a multicast packet to a certain lan/VLAN. It won’t transverse lans / vlans without explicit permission to do so (aka a multicast forwarding setup). So, if your esp device and your laptop are on the same lan/VLAN, you’ll be able to see it. If the esp device is on your lan and your Hass machine is on VLAN 20 and Hass sends a multicast packet, only VLAN 20’s multicast address is sent the packet. The lan multicast address will never see it unless your switch or firewall routes the packets to that destination network.

If you want other people to do all the work for you, maybe get a better attitude.

I am quite aware how multicast works and what VLANs are.
I am not sure where you get the attitude part. I am not expecting you to do all the work for me.

As I said in my first post:

  • I have mDNS repeater running which takes care of broadcasting mDNS packets between said VLANs
  • a computer in the same VLAN as HA can resolve the mDNS name of the ESP in question successfully
  • for some reason HA can not

I can also add that mDNS between my IOT VLAN and the HA VLAN generally works - new Shellies, etc. are automatically discovered. So this is something ESPHome specific. For example for TUYA devices, I also needed to proxy UDP broadcasts on ports 6666 and 6667 (not related to mDNS per se) between VLANs to make them work with localtuya integration.

So if you are saying “setup multicast forwarding”, I am asking which traffic specifically?

Possibly related. One commenter thinks switching framework to Arduino fixes the problem and problem occurs in ESP-IDF framework binary. ESP32 devices show offline, mDNS not working correctly · Issue #6311 · esphome/issues · GitHub

That is interesting, thanks. Will take a look.
Although someone in that thread writes that mDNS does not work from computer as well. For me it still works from a computer (MacOS), but not with ESPHome Device Compiler (which is inside a docker).

udp 5353 should be the protocol and port.

1 Like

Yeah, UDP 5353 is mDNS and that is forwarded between VLANs via mDNS repeater and as I said, mDNS resolving works from MacOS.

As far as I can see with tcpdump on the router, UDP packets originating in IOT VLAN interface to 224.0.0.251:5353 are forwarded to HA server VLAN and vice versa.

1 Like

I’m encountering the same issue. mDNS works on both VLANS, device add itself to mdns, home assistant has also it’s own entry but i’m unable to discover the device in device builder. Weird.

I think mdns broadcasts reach HAOS, but do not reach the container in which Esp builder runs. But I stopped diagnosing it.

Mdns doesn’t enter docker network unless you use host or macvlan networking for docker.

Mdns will work on individual vlan but will not work across vlan unless you add mdns reflector

I’m already using mdns reflector with avahi for other services.

Suggestion, try setting domain: .home in the wifi section of esp32 .yaml instead of the default .local, worked for me, ymmv, example:

manual_ip:
  static_ip: 192.168.4.214
  gateway: 192.168.4.1
  subnet: 255.255.255.0
domain: .home   ##was .local (default)

.local is reserved for mDNS implementation.
.home is nothing. You might have it defined somewhere in your dhcp server or local dns as search domain or something like that if it makes a difference for you, but it is by no means universal.

I agree that .home is nothing, but as I understand it, it is not .local which the espdashboard docker container can’t resolve. I think you could even set the domain to empty “”, and it will work, but try or don’t no worries.
From: .local domains are not accessible · Issue #3517 · esphome/issues · GitHub
if the problem is to be able to flash a device by OTA with esphome, you can add domain: "" to the wifi section in the .yaml file.

domain default is .local, and setting it to empty will allow you to reach your device from a docker container.

A functional workaround is to use static ip and ping in Device Compiler at the moment.
There is an open issue in esphome referenced by mterry63: ESP32 devices show offline, mDNS not working correctly · Issue #6311 · esphome/issues · GitHub, lets hope that will fix the mDNS issue in Device Builder properly at some point.