Changing the hostid in Linux

 Eric Williams | 14 November, 2011
linux sysadmin 

The hostid on some systems, like Suns, is set in the hardware and uniquely identifies the system. On Linux, the hostid is more of a suggestion than a hard-and-fast rule. It's usually generated at install time, and can be changed with a few lines of python code:

      from struct import pack
      hostid = pack("I",int("0x210a2500",16))
      filename = "/etc/hostid"

You can check this then with the hostid command.

  # hostid

Protip: It's always a good idea to back up /etc/hostid first, just in case.

This can help workaround issues with applications like flexlm, that naively assume that hostid is in some way significant on Linux.