Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4669
  • Last Modified:

hostid command outputs 0, how to generate hostid on Redhat Linux 4.6

We have a Redhat Linux 4.6 OS on HP DL585 G5 , hostid command outputs 0,
How to generate the hostid, or what should be done in this case, to have hostid setup.

Thanks in advance.
0
solven3
Asked:
solven3
  • 2
  • 2
3 Solutions
 
omarfaridCommented:
I am not sure how hostid get generated, but I have seen some comments on this on the Internet where it says that it is related to host ip address. What is the ip address of your system?

http://osdir.com/ml/user-groups.linux.madurai.general/2005-04/msg00023.html

Other page says it is related to the mac address:

http://www.mathworks.com/support/solutions/data/1-171PI.html?solution=1-171PI
0
 
joolsCommented:
running strace seems to indicate /etc/hosts is used, I just moved my /etc/hosts out the way and got this;

# hostid
00000000

moving it back and tunning it again;
# mv /etc/hosts.old /etc/hosts
# hostid
007f0100



0
 
omarfaridCommented:
So it is related to IP address and may be entry in /etc/hosts file
0
 
joolsCommented:
May also be something in the dns, mine just looked at the order in the hosts.conf and other files.

List of files ripped from the strace log are;

open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
open("/etc/hostid", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/etc/resolv.conf", O_RDONLY)      = 3
open("/etc/nsswitch.conf", O_RDONLY)    = 3
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libnss_files.so.2", O_RDONLY) = 3
open("/etc/host.conf", O_RDONLY)        = 3
open("/etc/hosts", O_RDONLY)            = 3
0
 
MysidiaCommented:
It appears to me that hostid does the following:

1. calls gethostname() [i.e. takes the hostname given by the output of the 'hostname' command in the shell]

2. Finds the entry in /etc/hosts that corresponds to the ip address of the hostname.

3. Copies octets from the ip address and prints them as a hex number:
AA.BB.CC.DD ==> 0x[BB][AA][DD][CC]

for example, if my hostname is 'foobar.example'

and my entry in /etc/hosts says

127.0.0.1 foobar.example

Then the hostid command prints '007f0100'



So to make 'hostid' not print zero... type the 'hostname' command after boot

Make sure there is an entry in /etc/hosts for that name.

Make sure that entry corresponds to a good ip address.

If you want the output to be unique, don't use 127.0.0.1



0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now