Avahi, which is an implementation of the Zeroconf protocol described in RFC6762, changes the hostname of the machine it is running on to a different one by adding a number at the end.
This anti-duplicate processus does not changes the hostname on the machine (so the others applications running on the machines will see and announce the same hostname) and if the machines are started in a different order, it is likely they will get a different hostname.
If you are looking for consistency and stability of the hostnames, this solution will not work.
There are different solutions to give each machine a unique hostname :
- modify your deployement process to give each installation a unique hostname (it can be a manual intervention),
- use a configuration management system to modify each installation after the initial deployement,
- make each machine generate random name (with a password generator like
pwgen
for example) at the first boot (or at each boot if your storage on the machines is read-only).
The most simple solution should be to change your deployement process, but you may need a configuration management system at some point.
For the last solution, I wouldn't recommend it in a small, personal deployement, it is likely that you will spend more time to make it work than you would have spend modifying each machine by hand. Also note that it is almost what you already have with avahi, except for the name persistence.