Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hostname questions



On Tue, Jul 17, 2001 at 03:39:01AM -0000, Jean-Christian Imbeault wrote:
> >Did you reboot? It is written by the startup scripts.
> >I think it is only there for informational purposes, though,
> >so you are not in trouble if it's not there.
> 
> Yes, I did reboot. It's still empty. Glad to know it's not really needed. 
> But then that begs the question . . . why is it there at all?

Probably you put it there at some stage :) It is not used on 7.1

> >Some do, but that's not really proper. They should get it by
> >calling /bin/hostname or something like calling gethostbyaddr(3)
> >on their own socket.
> 
> That's what I've been waiting for someone to say!! So now I know that 
> /etc/hosts doesn't need and shouldn't need an entry for my machine.
> 
> But I have to put as a hack against bad-mannered apps :)

Hang on a minute... The machine name and ip address *should* be put in
/etc/hosts, if you want your machine to work correctly. This is not because
of bad-mannered apps (who would be crazy to parse /etc/hosts themselves)
but because, if DNS drops off the face of the earth, your machine still
needs to be able to resolve its hostname/address. Forget about it finding
it in /etc/sysconfig/network, it just reads that at the start to know
how to set networking up... The machine on the kernel and driver level
is happy from the setup.

The problem is where applications need to know how names map to ip addresses
and vice-versa. They make standard library calls to functions like
gethostbyaddr() to resolve names/addresses as they go a long, this library
is responsible for resolving these and it uses either hosts.conf or 
nsswitch.conf to find out what databases to use to resolve hosts with.
This means it will probably look at the /etc/hosts "database" first and
then DNS. If your machine name/ip is in /etc/hosts all will be fine even
if DNS is down. If it is not there, the library is not going to be able
to find it and apache mightn't start and sendmail mightn't start and 
a whole host of other things mightn't start...

The moral of the story is, put it in /etc/hosts and /etc/sysconfig/network
not for no reason nor a bad reason but because that's how it is...

Tom.
-- 
Thomas O'Dowd. - Nooping - http://nooper.com
tom@example.com - Testing - http://nooper.co.jp/labs


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links