新闻  |   论坛  |   博客  |   在线研讨会
在Fedora16上修改hostid
my17sky | 2011-12-18 17:27:23    阅读:2526   发布文章

最近由于工作需要将Windriver Workbench3.2装在fedora上,装完后发现无法注册,因为hostname和hostid不一样,故需要修改。

我们知道hostid作为一台主机的唯一标示符(hostname本身可能重复),而许多付费软件通过鉴别hostid发给相关的license.

hostname的修改较为简单,只需要修改/etc/sysconfig/network中的hostname并重启即可。

hostid的修改就不那么方便了,下面介绍一种方法:

编辑一个c文件,是的之后你还需要修改它,就叫做host.c吧!

#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(0x11223344);
//括号内填入你想要的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);
 }

之后我们需要编译它

[root@pmsora ~]# cc host.c

[root@pmsora ~]# ./a.out                   //编译后运行

 current hostid is: a090d01
 if result is zero - success! (0)
 current hostid is: 11223344 ;-PPPppppp
 [root@pmsora ~]# hostid
 11223344                                         //hostid正确修改了
 

注意运行编译好的目标文件时必须使用root用户,而且hostid的长度最长为8个字符。

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
我要建一座城,住着幸福的子民。
最近文章
Qt之QTextCodec使用方法
2017-04-13 10:34:02
Lattice 时序约束
2013-05-27 09:48:26
Quartus II警告及原因
2012-11-02 16:25:46
推荐文章
最近访客