How can a computer running avahi ascertain and display its OWN hostname in the event that it is dynamically changed to foo-2, foo-3, etc due to hostname conflicts with other devices on the network?
When two computers (both with hostname = foo) that are running avahi-daemon and are on the same networks, as expected they can be accessed via ssh as foo.local
and foo-2.local
. Eg, the hostname collision is being handled correctly by avahi.
However, on both machines the command hostname
returns foo
. So that is not dynamically updated when avahi does it's hostname renaming.
What command will show the correct (dynamical) hostname to access a computer?
These are mobile devices, and I want to display "my hostname is XXXX.local' on each device so when more than one device is present the user know WHICH hostname to enter to go to "their' device.