As I've written about in the past (here), Apple's AirPlay technology relies on Bonjour which is Apple's implementation of "zero config" networking. One of the things that Bonjour enables is the automatic discovery of services on the network. For example, an Apple TV might advertise itself as being able to receive AirPlay streams. An iPad that is looking for AirPlay receivers would use Bonjour to discover the Apple TV and present it to the user as an AirPlay destination. Both the Apple TV and iPad do all this without any user intervention or configuration (hence the "zero config" part).

That's fine and dandy but what my earlier article focused on was how Bonjour broke down in a network where what I'll call the "server" and the "client" are not in the same Layer 2 domain/VLAN. This is because the service discovery aspect of Bonjour relies on link-local scope multicast. These packets will not cross Layer 3 boundaries in the network.

Bonjour packets will not pass a Layer 3 boundary

What's needed to make Bonjour work across subnets is a proxy that can take the service announcements on one subnet and announce them on the other(s) (and vice-versa). What's perfect about this is that service discovery works just like DNS. In fact, it is DNS: multicast DNS (mDNS). The DNS system provides a lookup service that sits out of band of the actual traffic flow. mDNS is exactly the same. The mDNS proxy will need a leg into each subnet where AirPlay clients and servers live, but it does not have to relay traffic between the subnets. It's merely the lookup mechanism. The reason I'm stressing this concept is because it means that the mDNS proxy can be deployed in the network without changing the network architecture. It also does nothing to change security zoning, doesn't affect the resiliency of the network and doesn't create a bottleneck for network traffic. It's a very simple way to address the need (demand?) for AirPlay in a business network. Eventually all the Wi-Fi vendors will have this kind of thing built into their products but for now, this gives the IT Network team the ability to say "yes, our network can support AirPlay".

The software I've used as an mDNS proxy is called Avahi. It appears to be the defacto open source software for service discovery and mDNS services. Yeah that's right, you can use it to advertise the services that are running on the local box (SSH, HTTP, etc). But what's really interesting is the setting that enables the "reflector" functionality.

[reflector]
enable-reflector=yes

This little knob in avahi-daemon.conf turns Avahi into an mDNS proxy where it will pick up service advertisements received on one interface and send them out on any other interface where a discovery query is received. The list of participating interfaces can be restricted using the allow-interfaces knob.

[server]
allow-interfaces=vlan10,vlan20
Bonjour packet flow with Avahi

As the diagram illustrates, this is the packet flow now between the iPad and the Apple TV:

  1. Apple TV advertises itself as an AirPlay receiver using Bonjour's Service Discovery mechanism
  2. Since the Avahi server is connected to the same VLAN as the Apple TV, it hears the advertisement and stores the details in its database
  3. The iPad uses Service Discovery to try and locate an AirPlay receiver on the network
  4. Since the Avahi server is also connected to the same VLAN as the iPad, it hears the discovery and responds with the information for the Apple TV
  5. Within the response from Avahi, the iPad will learn the IP address and port that it should connect to the Apple TV on. The iPad will initiate a direct connection to the Apple TV

Avahi is a really lightweight piece of software. It can run on a small UNIX machine β€” physical or virtual β€” and handle discovery messages on multiple VLANs. Avahi is present in all the major Linux distributions and in the OpenBSD and FreeBSD ports collections.

Go run it.


Disclaimer: The opinions and information expressed in this blog article are my own and not necessarily those of Cisco Systems.