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.
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 192.168.1.2
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 192.168.1.2 &
/usr/bin/avahi-publish -a -R picockpit.local 192.168.1.2 &
/usr/bin/avahi-publish -a -R papi.local 192.168.1.2 &
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.
If you want, you can test that the script works by running
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.
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.
Add a line for each device, e.g.
Save the file. Reload the avahi daemon (the reload may not actually even be necessary)
service avahi-daemon restart