Avahi how to assign several .local names to same IP

In some situations you would like to access the same computer / IP using different .local names.

This is possible using the Avahi daemon. The following is written for Ubuntu 18.04 Bionic Beaver.

Install Avahi

apt install avahi-daemon avahi-utils

Avahi automatically adds your computer’s hostname to the .local Domain. For instance, my computer is called morpheus.

Therefore it will be accessible using morpheus.local


By the way, if you want to access Zeroconf / Bonjour / Avahi .local domain names, you should simply install Apple’s Bonjour Print Services for Windows.

Make computer accessible under additional .local domain names

avahi-publish -a -R taxgod.local

The –R flag is important: it will allow you to publish several domain names for the same IP, as it will NOT publish a reverse entry with the address. (Otherwise, obviously the reverse entries would collide, and therefore avahi refuses to publish them).

The –a flag registers an address/host name mapping.

This command will run in the foreground. While it is running, the domain will be published, and you can access your computer using this additional domain name.

Making it permanent & backgrounding the command

Ideally we want this to happen on startup.

Create a startup script under /root/avahi-add-names.sh :


/usr/bin/avahi-publish -a -R taxgod.local &
/usr/bin/avahi-publish -a -R picockpit.local &
/usr/bin/avahi-publish -a -R papi.local &

Adjust the script with the names you want to have.

Make it executable

chmod +x /root/avahi-add-names.sh

Add the command using crontab.

crontab –e

@reboot /root/avahi-add-names.sh

If you want, you can test that the script works by running

nohup /root/avahi-add-names.sh

By the way, when you restart the avahi-daemon, you will need to restart this script, otherwise you will get the following error messages:

“Client failure, exiting: Daemon connection failed”


Here you can see that I can ping several different “aliases” .local domain names for the same IP.

Bonus Tip

If you want to publish .local domains for other computers / devices, which are not capable of publishing them for themselves, you can also do this with Avahi.

nano /etc/avahi/hosts

Add a line for each device, e.g. kyo3.local

Save the file. Reload the avahi daemon (the reload may not actually even be necessary)

service avahi-daemon restart