How to change Host ID for Linux

hostid เป็นคำสั่งที่ไว้ใช้ดู id ของเครื่อง Linux โดยเมื่อติดตั้ง Linux เสร็จระบบจะสร้าง host id ขึ้นมาและจะไม่ซ้ำกับ id เดิมในกรณีที่ติดตั้งใหม่ ดังนั้นโปรแกรมที่มีลิขสิทธิ์ส่วนมากจะอ้างอิง license กับ host id เพื่อป้องกัน…

การดู hostid สามารถใช้คำสั่ง hostid ดังตัวอย่างด้านล่าง

[root@Ezylinux ~]# hostid
007f0101


การแก้ไข hostid สามารถทำได้ดังนี้
ขั้นแรกต้องมี gcc (compiler) ก่อน ถ้าไม่มี ใช้คำสั่ง

[root@Ezylinux ~]# apt-get install gcc*  //สำหรับสาย debain

หรือ

[root@Ezylinux ~]# yum install gcc*      //สำหรับสาย red hat

ต่อมาสร้างไฟล์ชื่อ sethostid.c ใส่ code ข้างล่างลงไป และเปลี่ยนตรง sethostid ให้เป็น hostid ที่ต้องการ

#include
#include 
 
int main() {
long id,res;
id = gethostid();
printf("current hostid is: %x\n",id);
res = sethostid(0x11223344);  // แก้ไขค่า 11223344 เป็นค่าที่ต้องการ
if (res == 0) printf("if result is zero - success! (%d) \n",res);
id = gethostid();
printf("current hostid is: %x ;-PPPppppp\n",id);
}

จากนั้นให้ compile ด้วยคำสั่ง

[root@Ezylinux ~]# gcc -o sethostid sethostid.c

เมื่อ compile เสร็จจะได้ไฟลฺ์ชื่อ sethostid มา แล้วใช้คำสั่งด้านล่างเพื่อรันโปรแกรม

[root@Ezylinux ~]# ./sethostid

Related posts:

  1. How to install dig, host and nslookup commands on your system เมื่อต้องการรันคำสั่ง dig, host หรือ nslookup แต่เครื่อง linux ของคุณไม่มีคำสั่งดังกล่าวนี้...
  2. Yum, Yellow dog Update, Modified and How to use Yum Yum หรือ Yellow dog Update, Modified เป็นโปรแกรมจัดการ package...
  3. How to install Dell OpenManage Server Administrator (OMSA) Dell OpenManage Server Administrator (OMSA) เป็น software ที่สำคัญสำหรับผู้ที่ใช้เครื่อง...
  4. How to mount NTFS filesystem with read/write support on CentOS / RHEL linux NTFS filesystem เป็น filesystem ของทาง windows ซึ่งโดยปกติแล้ว Linux...
  5. Enable Telnet in Linux Server ใน Linux จะไม่อนุญาติให้มีการใช้งาน telnet เนื่องจากว่าไม่มีความปลอดภัยในการใช้งาน จึงได้ใช้ ssh แทน...

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply