I want to broadcast multiple host names on a local network only from a single instance of Ubuntu Server 10 with Zeroconf or something similar. It has to be zeroconf or similar because it's going to be used in a virtual machine configuration and will be copied around so I can't depend on an external DNS server. I've collected a number of resources, but haven't been able to figure it out. Is there a way to do this?

Here are some resources I've gathered: http://bit.ly/l5W4ab

EDIT: It would also be fine to set up VirtualBox to be a DNS server too.


You can configure Avahi to publish arbitrary hostnames using /etc/avahi/hosts, but you need to specify the exact IP address to map the hostname to. There doesn't seem to be a way to publish multiple hostnames to the IP addresses detected by Avahi. You could write a startup script which populates /etc/avahi/hosts after discovering the VM's IP address.

|improve this answer|||||
  • I ended up solving this problem an entirely different way, but I am tempted to come back to this problem and try this solution. It sounds promising. – Jonathan Swinney Apr 20 '12 at 14:34

Here's a little systemd service that lets you specify an alias for your current machine like test.local in addition to hostname.local (assuming your machine is called hostname).


First install avahi-utils, if you haven't already:

sudo apt-get install avahi-utils

Then put the following into /etc/systemd/system/avahi-alias@.service

Description=Publish %I as alias for %H.local via mdns

ExecStart=/bin/bash -c "/usr/bin/avahi-publish -a -R %I $(avahi-resolve -4 -n %H.local | cut -f 2)"


(The avahi-resolve is used to get the current IP address that is already being published for the hostname)


Then to make the current machine available as test.local in addition to its current hostname.local, you would enable the service with:

sudo systemctl enable --now avahi-alias@test.local.service

You can enable multiple aliases by starting multiple services, e.g. avahi-alias@test1.local.service and avahi-alias@test2.local.service, which makes use of systemd's multi-instance features:

sudo systemctl enable --now avahi-alias@test1.local.service
sudo systemctl enable --now avahi-alias@test2.local.service

Naturally you can disable each alias independently, too, with:

sudo systemctl disable --now avahi-alias@test2.local.service


|improve this answer|||||

I've used a small project named avahi-aliases before, its not in the debian repository, and seems to be a little less than maintained. Also on github here https://github.com/airtonix/avahi-aliases

|improve this answer|||||

Why not just set up your ubuntu server to be a dns and dhcp server and not worry about zeroconf? First, configure the dhcp server to give out addresses in some range sufficient for your needs. Then, set up a forwarding nameserver on the machine. These instructions are pretty similar to what you want to do. Basically you are allowing the dhcp server to change your dns server on the fly. Then when the other virtual machines on the network come up, they send their preconfigured names to the dhcp server. The dhcp server in turn sets those names in dns for your local domain.

Another very simple option is to set up something like DNSmasq. DNSmasq can read the server's /etc/hosts file and serve those entries up via dns to other machines on your network. So in this scenario you would maintain a big hosts file on the server of all the VM names, and the machine would again automatically serve those names over dns. You would still want to use dhcp in this case so the VMs could get addresses on your network automatically, but this is a simpler approach than configuring BIND for dns.

My suspicion is that dhcp + dnsmasq will probably work for you, unless you are attempting to run massive numbers of VMs.

|improve this answer|||||
  • The ubuntu server itself is the virtual machine. It needs to broadcast its own names without the help of an external DNS server. I need this to work for my coworkers in coffee shops, etc. Put the vm into host-only or shared (nat) mode and the vm should broadcast names itself. I just had another thought... if I could make virtual box (or vmware) be the local DNS server, that should work. – Jonathan Swinney May 11 '11 at 13:11

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.