wtf: hostid gives '0' as a hostid
cerise at armory.com
cerise at armory.com
Tue Feb 12 21:48:41 PST 2008
On Tue, Feb 12, 2008 at 04:10:29PM -0800, David Alban wrote:
> saw something today i've never seen before. on a linux box,
> /usr/bin/hostid printed '0' to stdout (plus a newline, of course).
> uh... isn't it supposed to be an eight digit hex number?
>
> i copied hostid from a box on which it was working correctly to /tmp
> on the "bad" box. when i ran /tmp/hostid it sill gave a hostid of 0.
> each of these boxes is *supposed* to be a clone at the hardware level.
>
> our environment depends on /usr/bin/hostid on each host working
> correctly. a cursory web search hasn't been enlightening. has anyone
> run into this before? if so, how did you fix it?
>
> --
> Live in a world of your own, but always welcome visitors.
hostid works by using the gethostid() POSIX call. In glibc, it's implemented
as trying to read /etc/hostid. If that fails, then it gets the ip address,
shifts it left 16 bits and ors that against the ip address shifted right 16
bits.
The lower 32 bits is what hostid prints.
hostid might be 0 because of your /etc/hostid. It might be 0 because of the
IP address or the contents of /etc/hostid.
(this is from coreutils 6.9 and glibc-2.7. YMMV.)
-Phil/CERisE
More information about the Baylisa
mailing list