假设你所指的是传统的unix hostid.如果我想将软件绑定到一个系统,我会使用加密狗或一些更强大的方法来识别一个看起来像hostid的系统是非常随意的,但是..
使用库调用“gethostid”检索hostid.它只是一个通用值,如果未设置将基于主机系统的ipv4地址.
见“man 2 gethostid”
In the glibc implementation,if gethostid() cannot open the file containing the host ID,then it obtains the hostname using gethostname(2),passes that hostname to gethostbyname_r(3) in order to obtain the host’s
IPv4 address,and returns a value obtained by bit-twiddling the IPv4 address. (This value may not be unique.)
您可以将文件/ etc / hostid放在您想要的值的位置(可能与您捐赠盒子上’hostid’程序的内容相同),将其自己设置为您想要的任何内容.
设置它虽然有点小问题..文件需要hostid的压缩二进制表示.
我使用python但你可以做任何事情……(很确定有人知道打印压缩字节更简单的方法).
from struct import pack
f = open('/etc/hostid','w')
f.write(pack('i',12345))
f.close()
这将以一种方式设置hostid,gethostid将返回与捐赠框相同的值作为迁移框.