14

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?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
bertyuan
  • 183
  • 1
  • 1
  • 10

2 Answers2

8

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.

Community
  • 1
  • 1
Linville
  • 3,613
  • 1
  • 27
  • 41
  • I'm wondering if this answer is no longer complete? I found this info very useful, but it seems there's now a fifth option to simply modify `avahi-daemon.conf` as @kristopolous's more recent answer suggests. – Michael Krebs Jan 09 '23 at 08:03
5

Sure you can. It's called a reflector and it's part of the Linux avahi daemon.

Look at "SECTION [REFLECTOR]" of man avahi-daemon.conf on your distribution.

kristopolous
  • 1,768
  • 2
  • 16
  • 24
  • 1
    This assumes that the Avahi daemon is running on the gateway, right? – Petr Nov 23 '21 at 13:24
  • 1
    no, you can run avahi on any host, as long as it has interfaces in both of the subnets you want to reflect between. – Ross Tajvar Feb 25 '22 at 08:05
  • 1
    I was looking at `smcroute` and other things to forward mDNS packets for me, but making this one-liner change worked for me: `enable-reflector=yes`. Thanks! I bothered to comment with a "thanks" in case somebody else comes here and isn't sure if the accepted answer is still correct and wondering if this can be done. – Michael Krebs Jan 09 '23 at 08:02