Linux – How to prevent Avahi adding -2 to hostnames

avahilinuxmdns

Often (maybe 80% of the time), when I reboot a machine running Avahi, it starts using machinename-2.local as it's hostname. All the machines on my network have unique hostnames, so there is no collision.

How do I prevent Avahi from appending -2 to hostnames?

(This turns out to be an incredibly difficult thing to Google for…)

Best Answer

This is also the case with OS X machines.

If the hostname is already in use on the network it bumps the counter to make the names unique again. I would suspect that the machine in question may have two netcards to the same network (cabled and wireless) or that you have a bonjour proxy running (which may be unknown to you) which helps sleeping machines by holding their hostname active. To be more certain you may want to describe your network better.