ESPhome over VLAN - hostname resolving

Tags: #<Tag:0x00007fc407236860>

Recently I started to move my IoT devices to a separate VLAN. Things are mostly working as expected, but it still needs some tweaking, but my biggtest problem is with ESPHome dashboard. The ESPhome “controller” is located on the untagged LAN network and it’s not able to resolve ESPhome nodes by hostname. In reality it means that upgrading nodes or viewing their logs from the ESPhome dashboard is not possible. HA communicates with the nodes via IP address instead of hostname, so HA control is flawless.

Summing up the situation:
LAN → VLAN hostname IS NOT resolved (e.g. nslookup returns no IP address)
VLAN → VLAN hostname IS NOT resolved VLAN device
VLAN → LAN hostname IS resolved

Now I suspect that the issue is related to mDNS.

My setup is OPNsense router + Unifi switch and APs.

In OPNsense there are firewall rules allowing access from VLAN to ports 53 and 5353 to the firewall gateway and also i have installed MDNS repeater plugin.
I have also enabled port 5353 from VLAN to 224.0.0.0/24 - this helped in terms that the nodes on ESPhome dashboard show up green instead of red, but hostname is still not resolved.

It seems i am still missing something. Also given the above i am not sure I understand what the colors mean in the ESPhome dashboard.

Any help is appreciated.

Go to the settings of the addon and tick “use ping”.

@sender, it did not help…

If homeassistant cannot resolve the hostnames it cannot reach the esps by ip because it doesn’t know it :-).

2 options:

  1. Make sure mDNS works between subnets (vlans) - this can be a PITA.
  2. Try excluding 1 esp in homeassistant and add it back by using the ip adress.

If 2 works, you may decide to use your own internal DNS and manually add the esp names and IP adresses and add those in homeassistant.

I have just added all esps by ip adress in homeassistant.

i have no problem controlling my devices on the VLAN via home assistant. my issue is only slightly related related to Home Assistant and ESPHome, i need to solve it on networking level. there’s a reason i posted into the Uncategorized section, although it seems some admin moved my post to the ESPHome section.

So what is the issue then? The esphome devices are “red” in the addon?

I run Adguard Home and manually assigned the IP’s to the hostnames in Adguard Home. Not the best solution but it works. (esphome_device_name.local)

this is my problem:


this happens despite the ESPhome devices being green.

i could assign manual hostnames to the devices, but i’d rather make mDNS work properly.

That is another problem.

try adding in the esphome yaml file below

wifi:
  use_address: 192.168.6.50

(use your own adress)

i would really like to solve this via mDNS. interesting thing i noticed that in some cases the hostname is resolved. what i realized is the following:

  • ip address assigned via DHCP: hostname is resolved on VLAN
  • fixed IP address set: hostname is not resolved

why is this happening?

EDIT: had to enable Register DHCP static mappings in Unbound DNS

Can you elaborate on how you fixed this and where you found this setting? I’ve been having these same issues since I moved my home assistant from RPi3 to a virtual machine on an intel nuc. This has been one of the bigger headaches that I’ve never gotten resolved. I’m also on Unifi AP’s with an EdgeRouter for DHCP. Thanks

@Robby_C i am not familiar with EdgeRouter, so I can only give a general approach:

  • devices on the VLAN should access UDP port 53 on the router via firewall rule
  • there should be a firewall rule enabling access to UDP 224.0.0.251:5353 from the VLAN
  • mDNS repearing across VLANs should be enabled
  • DHCP server should register hostnames for your VLAN

no guarantee, give it a try

I also had some issues resolving my esphome’s
For me adding

domain: .mydomain.xyz

to esphome yaml solved it (as mydomain.xyz is defined as my local dns name on my edgerouterx)