MDNS Across Unifi VLANs

I started working on some hardware projects related to home assistant using the ESP8266. in working on these I learned that the ESP devices use mDNS to advertise their hostnames for communicating with them. My devices however are on a separate VLAN that’s unable to communicate with the internet, and that VLAN was also blocking the mDNS updates from making it through to home assistant, keeping it from being able to know the hostnames. I could use static IPs for this, however I want to avoid locking all my little smart devices to static IPs.

Getting those mDNS updates across the VLANs takes two steps. It starts with enabling the mDNS repeater in the Unifi controller. This repeater however doesn’t work fully across VLANs without a little magic.

Turn on the mDNS Repeater

The magic comes in the form of a LAN_IN firewall rule that allows through those mDNS packets between the VLANs.

Magic Networking Firewall Rule

Conclusion

This ended up working well. The mDNS updates from my ESPHome devices started making it through to the VLAN hosting my home assistant server. I was able to ping the devices using their hostnames and from there also configure home assistant to use the hostnames instead of IP addresses. This lets me avoid setting all my ESPhome devices to static IPs.

Resources

Leave a Reply