![](/img/trans.png)
[英]How to create a function that generates a unique password for each machine in linux?
[英]How can I create unique identifiers for each machine in Linux or Perl?
我在许多机器上运行一个Perl脚本,该脚本会将一些数据存储到MySQL数据库中。 我需要知道数据源。
我不能使用hostname,因为某些计算机的主机名是'localhost'。
ifconfig
给出随机设备和IP,一些eth0
,一些eth1
,一些其他设备名称。
还有其他方法可以为每台计算机创建唯一标识符吗? 而且,每次我运行Perl脚本时,此唯一标识符都不会更改。
除了先前对genhostid的调用之外,还应该使用hostid ,该调用将生成并存储机器的唯一ID(因此,每次调用该ID都不会改变)。
dmidecode
的输出提供了许多硬件UUID和序列号,您的perl脚本可以利用这些序列号。 引用dmidecode的手册页:
dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision.
我发现最好的方法是第一次生成具有随机ID的文件,并在文件存在后使用文件内容。 我把它放在/ etc的某个地方,但这没关系。
这可以容忍系统配置更改,但是需要一些额外的工作才能进行远程查询。
取MAC地址并修改它?
ipconfig -a
要么
arp
解析?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.