6

What I would like is to use avahi-daemon to multicast more then one name. So that I could connect to it with domainA.local domainB.local.

I could then reroute these addresses to a different web interface of different applications with nginx.

Is it possible to configure the avahi-daemon in such a way that it would multicast multiple names?

P.S. Using the avahi-daemon is not a requirement. If there is another program that has this functionality I would gladly switch.

Research and results

So as suggested by gollum, I tried avahi-aliases first. It is in the repositories, but it did not appear to have installed correctly on my system. According to the instructions is should have installed a script in /etc/init.d/, but there was none.

I then gave the other link that gollum suggested a try and this worked straight away. It does depend on python-avahi and is just an example of a python script that needs to run in the background. I am now able to broadcast domainA.local, domainB.local and domainC.local and in combination with nginx that leads to different web interfaces on the machine, but are all accessible on port 80.

Update

After some more fiddling with the two, I also discovered that avahi-aliases can only broadcast subdomains. So if your computername would be elvispc then avahi-aliases can only broadcast subdomainA.elvispc.local and subdomainB.elvispc.local, where the python script will broadcast any name.

  • I don't have the problem mentioned that the Airtronix avahi-aliases script can only broadcast "subdomains" (and as the Avahi part of this script is almost identical to the original Avahi wiki Python script it would be surprising if they behaved differently). – George Hawkins Feb 22 '17 at 22:42
11

A cumbersome solution would be running several instances of the following command in background:

avahi-publish -a -R whatever.local 192.168.123.1

A better solution is probably publishing cnames using python-avahi. See e.g. https://github.com/airtonix/avahi-aliases or http://www.avahi.org/wiki/Examples/PythonPublishAlias

Update:
The avahi wiki seems to be gone. Here is the archived page of the link I've posted: https://web.archive.org/web/20151016190620/http://www.avahi.org:80/wiki/Examples/PythonPublishAlias

| improve this answer | |
  • 1
    And it would be great if you could post your final solution after your research ... – gollum Jan 15 '16 at 13:08
  • It took a bit longer than expected, sorry for that. Will add my results to my post and accept your answer. Thank you for your help! – larzz11 Jan 18 '16 at 8:53
  • Dead link to the avahi wiki. The GitHub solution you posted doesn't work on Ubuntu with Python 3 - only Python 2. – starbeamrainbowlabs Nov 20 '19 at 1:26
2

First off Avahi doesn't seem to support aliases directly, through one of their standard commands, but their website (essentially offline since sometime in 2016) used to host a very short and simple Python script that would do this.

With this script you can advertise any number of CNAMEs for your current machine like so:

$ ./avahi-alias my-alias.local my-second-alias.local

I did a lot of Googling into all this and you can see my resulting write up here. There's a copy of the original wiki script there and instructions on how to get it running as a service.

The write up also includes my notes on all the various Avahi aliases projects that you can find out there (including the Airtronix project already mentioned here). They all turn out to be just slight variants on the original Python script except for a Ruby based one that's part of the OpenShift Origin server project.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.