I need to uniquely identify a machine despite it having multiple IP addresses(which a common scenarios for linux machines) what I am thinking of is to use hostname as an identifier for the machine/system(host name in /etc/hostname). Is it mandatory that a system will have only one hostname or a system can have multiple host names.
Any help appreciated.
I would identify it as some combination of hostname, MAC address, processor serial number, and hardware serial number. This may not be possible with virtualization, though a virtualized machine should have a unique MAC, unless someone has duplicated it.
Also, I’d get the hostname with uname -n rather than parsing /etc/hostname. Not all Unixes (HP-UX) use /etc/hostname, so this increases portability.