Are you know how to Change Linux Host ID ?
The host address, or the host ID portion of an IP address, is the portion of the address used to identify hosts (any device requiring a Network Interface Card, such as a PC or networked printer) on the network. The network ID, by contrast, is the portion of the address that refers to the network itself (wikipedia). We can check Host ID in our computer with command :
1 2 |
toto@toto-laptop:~$ hostid 0x007f0100 |
This Host ID is default from my computer. We can change Linux Host ID manually. This is my code to Change Linux Host ID. Copy this code and save as ChangeLinuxHostId.c :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <stdio.h> #include <unistd.h> int main(int argc, char **argv) { int id,res; int newid; sscanf(argv[1], "%x", &newid); // get default hostid id = gethostid(); printf("Current Host ID is: %x\n",id); // login as super user and change host id res = sethostid(newid); if (res == 0) printf("succes change Host ID \n"); else printf("fail change Host ID \n"); // check if it is changed.... id = gethostid(); printf("New Host ID is: %x\n",id); return(1); } |
We can compile this C/C++ Code Change Linux Host ID (ChangeLinuxHostId.c) with command :
1 |
gcc ChangeLinuxHostId.c -o ChangeLinuxHostId |
We can running this C/C++ Code Change Linux Host ID as superuser. This is sample output when we Change Linux Host ID from above code :
1 2 3 4 |
toto@toto-laptop:/home/toto$ sudo ./ChangeLinuxHostId 0x007f0500 Current Host ID is: 7f0100 succes change Host ID New Host ID is: 7f0500 |
This is output when we try to check our new Linux Host ID :
1 2 |
toto@toto-laptop:~$ hostid 0x007f0500 |
This is a simple method how to Change Linux Host ID with our code program. If you have any other method, please share.
source : http://www.edaboard.com/thread5989.htmlMy name is Toto Sugito. This is my notes when I try something. Maybe, this is NOT THE BEST SOLUTION for your problems. If you have other method or idea that better with my post, please share in this blog. Thank for visiting my site.