简体   繁体   中英

How to generate an unique ID for a given linux machine?

My python application running as a daemon in a variety of linux distributions are trying to register to my server using the machine's IP Address and FQDN Hostname(given by "hostname -f" command) as a primary key.

Now I am facing a problem when two machines are having same hostname and IP Address. Eg in case of two VM's running on two seperate machines, the hostname is "localhost.localdomain" and Ip Address is "192.168.0.2" for both of them.

Is there any unique way to differentitate any two machines. (Maybe some other third parameter which will guarantee uniqueness across any linux machine )

the MAC address should be unique per network interface. maybe you can try a combination of IP, MAC and host name?

another option is to create a UUID and save it on the machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM