Solved

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

Posted on 2008-10-10
8
3,916 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
  • 2
  • 2
8 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 168 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 166 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 166 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now