?
Solved

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

Posted on 2008-10-10
8
Medium Priority
?
4,472 Views
Last Modified: 2013-12-06
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
Comment
Question by:solven3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 672 total points
ID: 22687439
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
 
LVL 19

Assisted Solution

by:jools
jools earned 664 total points
ID: 22687491
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 22687519
So it is related to IP address and may be entry in /etc/hosts file
0
 
LVL 19

Expert Comment

by:jools
ID: 22687564
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
 
LVL 23

Assisted Solution

by:Mysidia
Mysidia earned 664 total points
ID: 22691705
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question