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
Solved

Hostname keeps changing

Posted on 2004-03-26
16
988 Views
Last Modified: 2013-12-16
Hi there,

I run the Core Dstro with a number of extra packages installed with the help of (B)LFS. I have a strange problem: my hostname 'corelinux' changes at random times to '-f' ...???

I've searched allmost every script now, but can't find any hostname-changing-commands...

Help? Please?

Harold...
0
Comment
Question by:aling
  • 6
  • 5
  • 2
  • +3
16 Comments
 
LVL 7

Expert Comment

by:troopern
ID: 10689335
have you checked your /etc/hostname file ?
or /etc/hosts ?
0
 
LVL 14

Expert Comment

by:xberry
ID: 10689395
edit your /etc/sysconfig/network file & put

HOSTNAME= 'corelinux'

there

then #hostname corelinux

reboot your system
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10689404
I'd have a look at your dhcp client. Most probably, it's invoking a script post lease issuance.

Which dhcp client are you using ?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:aling
ID: 10690200
OK:

'/etc/hosts' file:
127.0.0.1 localhost
127.0.0.1 corelinux

exerpt from '/etc/rc.d/rc.si'
# setup network [internet connections go in rc.mu]
hostname corelinux
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.0.0.0 lo

exerpt from '/etc/rc.d/rc.mu'
# setup network
ifconfig eth0 192.168.0.20 netmask 255.255.255.0 up
route add -net 192.168.0.0/24 dev eth0
route add default gw 192.168.0.1

I don't use a DHCP  client nor RedHat so I also dont have a /etc/sysconf...

I do have this prompt occasionally :-)

[root@-f] ~ > hostname
-f

Hope to help you helping me with this...

Harold...
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10690317
Ok. Change the following in your /etc/hosts :

192.168.0.20<tab>corelinux

And get rid of the second 127.0.0.1 line.

I don't know if this will solve your problem, but it can't be bad.

Some script somewhere is trying to get your fqdn hostname using "hostname -f".
And, for a reason I don't know, it's in fact setting your hostname to "-f"...
Weird.

Does it happen after you start a new X environment ?

You can try the following command to narrow the search :

find /etc/ | xargs grep -- "hostname -f"
0
 
LVL 12

Expert Comment

by:paullamhkg
ID: 10692962
Agree with Alf666 that should be change the name of your linux box with the IP

127.0.0.1 is for local loop.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10695539
> I do have this prompt occasionally :-)
sounds like you have an alias or function which is mal-programmed
please post results of:
  set|grep hostname
  alias|grep hostname
0
 

Author Comment

by:aling
ID: 10702874
Gentlemen,

find /etc/ | xargs grep -- "hostname -f" -> no result
set|grep hostname && alias|grep hostname -> no result

I've looked at the hostname man pag (http://www.die.net/doc/linux/man/man1/hostname.1.html) and none of the command line options work with my hostname binary. For example: hostname -d sets the hostname to '-d' instead of returning a value...

Perhaps things will change if I mak a fresh install of Coreutils-5.0?
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10702900
Yes. There is also a chance you have multiple hostname commands on your system.
If you have installed locate, try :

locate hostname

This definitely explains why your hostname changes to "-f" sometimes.
Lots of scripts (including XFree startup scripts) use the hostname command to know who they are.
0
 

Author Comment

by:aling
ID: 10702918
Result of locate hostname:

/bin/hostname
/usr/lib/perl5/5.8.0/hostname.pl
/usr/man/man1/hostname.1
/usr/share/man/man3/BIO_get_conn_hostname.3
/usr/share/man/man3/BIO_set_conn_hostname.3
/usr/src/ocaml-3.07/otherlibs/unix/gethostname.c

I'll compile/install today, maybe that will fix things up...

Harold.
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10703017
That shoud definitely.
I don't know where that hostname command comes from, but it's suspicious.
0
 

Author Comment

by:aling
ID: 10703311
OK,

Here's how I reinstalled coreutils:

coreutils-5.0 (ftp://ftp.nluug.nl/pub/gnu/coreutils/coreutils-5.0.tar.gz)
- tar zxvf coreutils-5.0.tar.gz
- cd coreutils-5.0
- ./configure && make && make install
- mv /usr/local/bin/* /bin -f

(I didn't use the --prefix=/ to be shure that the current binaries are overwritten)

[root@corelinux] / > hostname
corelinux
[root@corelinux] / > hostname -f
[root@corelinux] / > hostname
-f
[root@corelinux] / >

As you'll see, no results here... ;-(
0
 
LVL 9

Accepted Solution

by:
Alf666 earned 500 total points
ID: 10704210
Ok. Just got it.

the hostname version from core-utils sucks. It's a very basic one. Juste recompiled it and checked the source.

Get the nettools :

http://www.tazenda.demon.co.uk/phil/net-tools/

They're the ones bundled with most distribs.

Your system will feel much better after that.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10704294
if hostname -f does not return a FQDN, then there is none configured
what contains your /etc/resolv.conf
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10704788
ahoffmann : Nope. This specific version of hostname does not accept any argument (I checked the sources). If you "hostname -f", then your hostname IS "-f" :-(

Hence the proposal to use a proper version.
0
 

Author Comment

by:aling
ID: 10704928
Congratulations!

EE has proven worthy again!

I did had some probs compiling net-tools...

Quote from google search about compiling net-tools on kernel 2.6.x:

Net-tools' make process aborts with a missing declaration about the variable
"x25_address". That is because in the header file <linux/x25.h> there used to
be a typedef for this variable. Nowlonger it does not, being replaced by a
structure of the same name. This problem is easily worked around by acting as
follows: the file x25_sr.c in the lib/ subdirectory of the net-tools suite is
the source of the problem. In line 80 it uses the sizeof() operator to get
the size of the structure x25_address included from the "#include
<linux/x25.h>" line. The workaround I used was to add a line

struct x25_address x25_address_priv

to the beginning of the relevant function, X25_setroute() and change the line
80 use of sizeof(x25_address) to sizeof(x25_address_priv). This gives
sizeof() a structure named x25_address_priv of type x25_address which solves
the problems.

...net-tools-1.60 compiled and installed correctly and replaced my bogus version of hostname...

hostname -f now returns my hostname!!!

Thank you all for contributing to this Q! The points go to Alf666 for pointing out the net-tools package...

Thanx...

Harold.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
installing docker on ubuntu 6 36
AWS ELB 5 95
expand ext4 on centos 6 5 37
Running linux commands into linux system remotely using powershell 6 42
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

856 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