Gandem / bonjour-reflector

A reflector that forwards mdns packets between VLANs - like avahi-reflector but with fine-grained control !
MIT License
177 stars 37 forks source link
avahi avahi-reflector bonjour bonjour-discovery bonjour-reflector mdns mdns-repeater vlan

bonjour-reflector

About this project

Bonjour-reflector makes Bonjour devices such as printers, Chromecasts or Spotify Connect speakers, discoverable and usable by other devices located on different VLANs.

Compared to other tools such as avahi-reflector, Bonjour-reflector allows a more fine-grained control of how Bonjour traffic is reflected across VLANs.

How it works

Bonjour-reflector works by intercepting all mDNS traffic and rewriting layers 2 and 3 of the packets to reflect them across the appropriate VLANs.

A configuration file lists, for each Bonjour device (defined by its MAC address), which VLANs should have access to this device. mDNS packets will only be forwarded if the configuration file says so.

The interface on which Bonjour-reflector runs should be configured so that it receives each VLAN's traffic, tagged.

In detail, here is what happens when Bonjour-reflector runs:

Installation

A Golang version more recent than Go 1.16 is recommended to build bonjour-reflector. Checkout https://golang.org/doc/install for instructions on how to install a recent version of Golang.

To build the binary, run:

go build

One of the dependencies of the project (gopacket/pcap) also needs the libpcap header files to work properly. On Linux-based distributions, you can do this by installing the development version of libpcap (package: libpcap-dev).

App setup

First, indicate in the config.toml file which of your network interfaces you want to listen to.

Then run

./bonjour-reflector -config=./config.toml

(you may need to run this line with administrator privileges to listen to your interface).

You may use any configuration file you want (following the same structure as the template ./config.toml file provided) by specifying its path with the -config option.

Contribution

Help on this project is very welcomed. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:

Debugging & Profiling

A pprof server will listen on port 6060 if the you use the -debug flag.

More information on pprof is available here

License

MIT