Could I use avahi to publish service across subnetworks?

bertyuan picture bertyuan · Jan 8, 2014 · Viewed 8.8k times · Source

Avahi is usually used for service discovery. I want to make a service discoverable from a different subnetwork, could I use avahi to achieve this?

For example, the service host ip is "192.168.1.100" with mask "255.255.255.0", so it's in 192.168.1.X subnetwork. Another host ip is "192.168.2.100" with mask "255.255.255.0". Could I use avahi to let this host discover the previous service host?

Answer

Linville picture Linville · Jan 8, 2014

Unfortunately, no, it's going to require reconfiguration of whatever device is routing between those two subnets. mDNS uses the multicast addresses 224.0.0.251 for IPv4 and ff02::fb for IPv6. Those are link-local addresses and the data sent to them is typically not routed outside of the current subnet.

There are various options, some may be easier than others depending on what your routing device is.

Multicast Proxying. mdns-repeater is a simple solution that will repeat mDNS requests across interfaces.

Wide Area DNS. Wide-Area DNS-SD could be enabled on the DNS resolver that is service the hosts in those subnets. Avahi could then be configured to publish not the .local domain but to the domain for those subnets.

Multicast Routing. The device routing between those subnets could be configured to route the multicast groups between those two subnets.

mDNS Gateway. There is a draft RFC for implementing a mDNS gateway that sits at the edge of a network segment (typically a router). This is not a simple repeater/reflector, but a gateway that caches service entries and responds to queries from other connected network segments.