我们知道hostid作为一台主机的唯一标示符(hostname本身可能重复),而许多付费软件通过鉴别hostid发给相关的license. hostname的修改较为简单,只需要修改/etc/sysconfig/network中的hostname并重启即可。 hostid的修改就不那么方便了,下面介绍一种方法: 编辑一个c文件,是的之后你还需要修改它,就叫做host.c吧!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <stdio.h>
#include <unistd.h>
int
main() {
long
id,res;
// get real (default) hostid
id = gethostid();
printf(
"current hostid is: %x\n"
,id);
// set new hostid if is superuser
res = sethostid(0xa090d01);
//括号内填入你想要的hostid
if
(res == 0) printf(
"if result is zero - success! (%d) \n"
,res);
// check if it is changed....
id = gethostid();
printf(
"current hostid is: %x ;-PPPppppp\n"
,id);
}
|
1
2
3
4
5
6
7
|
[root@pmsora ~]
# cc host.c
[root@pmsora ~]
# ./a.out //编译后运行
current hostid is: a090d01
if
result is zero - success! (0)
current hostid is: a090d01 ;-PPPppppp
[root@pmsora ~]
# hostid
0a090d01
//hostid
正确修改了
|
本文转自maclean_007 51CTO博客,原文链接:http://blog.51cto.com/maclean/1277071