I have a license server. The hardware is failing.

The license software depends on the 'hostid' of a system returned by /usr/bin/hostid. hostid is unique "numeric identifier for the current host".

If I migrate the software to another host, it seems that the 'hostid' will change and the license software will fail. Note that the hostname and ip address of this system will remain the same.

Two questions:

  1. How is the hostid determined? Is it random, does it depend on the hostname or MAC address, etc?

  2. Can I set the hostid on a new system so that it matches the hostid of the old system?


Assuming here what your referring to is the tradiitional unix hostid. If I wanted to bind software to a system I would use a dongle or some stronger means to identify a system seeing as a hostid is very arbitrary, but nevertheless..

The hostid is retrieved using the library call "gethostid". Its merely a generic value which, if unset will be based off of the ipv4 address of the host system.

See "man 2 gethostid"

In the glibc implementation, if gethostid() cannot open the file containing the host ID, then it obtains the hostname using gethostname(2), passes that hostname to gethostbyname_r(3) in order to obtain the host's IPv4 address, and returns a value obtained by bit-twiddling the IPv4 address. (This value may not be unique.)

You can set it yourself to anything you want by putting the file /etc/hostid in place with the value you want (presumably thats the same as what comes out of the 'hostid' program on your donating box).

To set it is a little tricker though.. the file required a packed binary representation of the hostid.

I used python but you can do whatever.. (pretty sure someone knows an easier means to print packed bytes).

from struct import pack
f = open('/etc/hostid', 'w')
f.write(pack('i', 12345))

This will set the hostid in a manner for which gethostid will return the same value as the donating box as the migrating box.


Afaik the hostid is either the MAC address of the (primary?) network card, or some kind of mixed identifiers with other values such as ip addresses (this heavily depends of the kind of *nix you run).

I guess, it should be possible to "fake" this value on any system (at least the mac address can be overridden). However, the best way is to ask the software vendor to transfer the license to the new system. I see no good reason why this should not be possible.

  • I oversimplified my example. This server runs multiple license servers, and changing each license will be very time consuming. – Stefan Lasiewski May 9 '12 at 17:53
  • 1
    Maybe time consuming, but the better way than dealing with weird bugs changing hardware ids WILL introduce. – ercpe May 9 '12 at 17:58
  • Had to downvote, sorry. Man pages clearly explain how a hostid is set. – Matthew Ife May 9 '12 at 18:15
  • 1
    At my work we have many license servers. Whenever they talk about the hostid, they mean the mac address. Some license servers don't like linux systems using em# instead of eth# ( in case you are planning on migrating to something like Fedora ). If you clone the mac of the old server, you will need to put it on a different L2 domain, typically done via a different subnet. That would mean you have a different IP address, so your clients that use it would need to be redirected to the new license server. – becomingwisest May 9 '12 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.