Need Bonjour across VLANs? Set Up an Avahi Reflector!

I can honestly say I don't know a single person that likes Bonjour. Or at least, not anyone who is network-savvy. Bonjour, Apple's proprietary Zeroconf mDNS system, is great for home use. In a small home network, it makes connecting Apple devices together easy. But Bonjour simply wasn't built for large, enterprise networks with multiple VLANs.

Several vendors have come out with solutions for this that repeat the Bonjour traffic across multiple VLANs. But never fear, you can do this for free all by yourself in a few simple steps! While repeating traffic across all VLANs really isn't a great fix for super large networks, it'll work well enough for an elementary school sized network.

**STEP 1 - Find Some Hardware and Install Ubuntu**
Avahi runs on basically anything Ubuntu can run on. You also only need one ethernet port (not doing any fancy bridging or anything). For Ubuntu, I used 14.04 LTS server edition. My Ubuntu with Avahi installation uses around 220mb RAM so pretty low spec.
**STEP 2 - Install Avahi**
After your initial Ubuntu installation and configuration, install Avahi and some supporting packages.
>sudo apt-get install avahi-daemon avahi-utils vlan

This will install the main Avahi process, some utilities for monitoring Avahi, and support for VLANs respectively.

**STEP 3 - Edit Avahi Config File**
We will want to modify /etc/avahi/avahi-daemon.conf so open it in vi, nano, or whatever your favorite text editor is. >sudo nano /etc/avahi/avahi-daemon.conf

Now find the line that says #enable-reflector=no and change it to enable-reflector=yes and save. Do not change any other settings - I made the mistake of filling in my host name and domain name in the config file and it broke don't do it.

**STEP 4 - Set Up VLANs on the Switch's Ethernet Port**
Now we'll need to configure the ethernet port to be on multiple VLANs. This part is unique based on who your vendor is. Basically, you'll want your Avahi server untagged on your server VLAN and tagged on the VLANs that you'll be "reflecting" to.
**STEP 5 - Set Up VLANs in Ubuntu**
We will first need to get the VLAN module we installed into the kernel by running `sudo modprobe 8021q`

Now for each VLAN you are tagged on, you'll want to add to your eth0 adapter. We can run sudo vconfig add eth0 <vlan> and it will create a sub-interface of eth0 on that VLAN. For example if my server is on VLAN 1 and my wireless clients are on VLAN 2, I will run:

sudo vconfig add eth0 2

Now we have to enable DHCP on that sub-interface by running sudo dhclient eth0.<vlan>. For my example:

sudo dhclient eth0.2

**STEP 6 - Restart Avahi**
Restart the Avahi service by running: >sudo service avahi-daemon restart
**STEP 7 - Add to Startup**
Unfortunately these changes won't persist between reboots. That's not a bad thing because if something went wrong, you could just restart and start over. Assuming these worked well, we want to save these settings. First, let's add the vlan module to Ubuntu permanently: >sudo su -c 'echo "8021q" >> /etc/modules'

Then open up your /etc/network/interfaces and add these two lines for each VLAN sub-interface you created:

auto eth0.<vlan>
iface eth0.<vlan> inet dhcp

Lastly, reboot the machine and you should be good to go.

Big thanks to the spiceworks community guide that helped with this in our environment! Run into any issues? Shoot me a comment below!

Posted on
Tagged in Ubuntu
chris reinking

comments powered by Disqus