Friday, 3 July 2015

For those of us in computing Zero-config or Bonjour or Avahi is the bane of our lives, especially when trying to shoe horn it into an enterprise network because it will not travel across vlans,  Bonjour packets will not pass a Layer 3 boundary. What's needed to make Bonjour work across subnets is a proxy and here is a free open source working alternative......

There are many off the shelf products out there which do the job but you usually have to pay a fortune for the privilege.....

Well I've just implemented an Avahi reflector using nothing more than a cheap laptop running Debian 8 (Jessie) and a network cable and made it work over 20 vlans

All you need is a network port on a switch (ours are Cisco 3750's) which can give you a 8021q trunk connection, a pc, it doesn't have to be high powered ours is running on an Atom cpu on 2GB of ram, it doesn't actually need that much it currently sits in 351MB of memory running at full tilt, it barely tickles the cpu's .....

So install your headless debian server (there are many how to's out there)

load vlan and modprobe it into the kernel

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

setup your vlans on eth0 

vconfig add eth0 50  # or whatever it's called

repeat and rinse until you've added them all

go edit your /etc/network/interfaces

and put in each vlan with a fixed IP address in the form of

 iface eth0.50 inet static
auto eth0.60
iface eth0.60 inet static
auto eth0.120
iface eth0.120 inet static

My 50 vlan has a gateway so that it can get updates and be ssh'd into remotely
but it's not necessary it will work without a gateway

so include all of the vlans you want to rebroadcast the bonjour packets on, make sure that you aren't using an IP address already assigned on the vlan in question, best way to avoid this is to put an exclusion in your DHCP server in each vlan and use the same last number on each vlan 

In my case I've assigned 10.11.XXX.9 to all of my fingers in the vlans so to speak

then edit avahi-daemon.conf in /etc/avahi and turn on 


you may have a problem with avahi stopping because of a unicast local problem but you can work around that by editing crontab for root and simply putting this line in 

* * * * * rm -rf /var/run/avahi-daemon/disabled-for-unicast-local
0 * * * * service avahi-daemon restart

the first line stops the avahi-daemon shutting down because of a .unicast local problem and restarts it every hour, and keeps deleting the file if it reappears.....

go back into the terminal and check with ifconfig that all your vlans are sending and receiving data

eth0.233  Link encap:Ethernet  HWaddr c8:9c:xx:xx:xx:xx  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::ca9c:dcff:fe84:cb9f/64 Scope:Link
          RX packets:1338 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17959 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:567767 (554.4 KiB)  TX bytes:4442622 (4.2 MiB)

eth0.240  Link encap:Ethernet  HWaddr c8:xx:xx:xx:xx:xx  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::ca9c:dcff:fe84:cb9f/64 Scope:Link
          RX packets:16884 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2635 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5503572 (5.2 MiB)  TX bytes:1168738 (1.1 MiB)

and bobs yer uncle....

fire up your ipad and you'll see everything on every vlan, it also allows you to see all of your Apple TV's over every vlan and wifi and even allows you to connect your Apple TV's to ethernet cables rather than relying on wifi connections. You'll also see all of your VNC and SFTP and anything else broadcast on mdns 

I've also managed to get airprint working on non airprint printers, using linux CUPS ...if you're interested in implementing it drop me an email, it will work with ANY printer.

Enjoy !!!! 

No comments: