You are not logged in.

#1 2007-09-01 11:32:58

TreeMinds
Member
Registered: 2007-09-01
Posts: 35

/etc/hosts correct format ?

What is the correct format for the /etc/hosts file ?  Found in ArchWiki 2 different
here : http://wiki.archlinux.org/index.php/Configuring_network
127.0.0.1               banana.localdomain             banana

& here : http://wiki.archlinux.org/index.php/LAMP
127.0.0.1               localhost.localdomain           localhost banana

Both of them are correct?

Offline

#2 2007-09-01 11:37:59

Eliteforce
Member
Registered: 2006-03-26
Posts: 56

Re: /etc/hosts correct format ?

yes

first comes the ip-address, then a list of names

Offline

#3 2007-09-01 11:40:05

TreeMinds
Member
Registered: 2007-09-01
Posts: 35

Re: /etc/hosts correct format ?

So in the second one you have 2 names localhost & banana
and in the first you have only banana for hostname?
Thanks a lot.

Offline

#4 2007-09-01 11:59:49

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: /etc/hosts correct format ?

You should always have localhost and localhost.localdomain - add anything else you need after those.

Offline

#5 2007-09-01 12:41:33

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: /etc/hosts correct format ?

I experienced lag when loading webpages when I had separate entries for /etc/hosts. When I put all entries on the same line, everything works nicely. Like in the beginner's guide in the wiki:

127.0.0.1  yourhostname.domain.org   localhost.localdomain   localhost yourhostname

FWIW smile

Offline

#6 2007-09-01 14:26:47

AlmaMater
Member
Registered: 2007-02-28
Posts: 92

Re: /etc/hosts correct format ?

Misfit138 wrote:

I experienced lag when loading webpages when I had separate entries for /etc/hosts. When I put all entries on the same line, everything works nicely. Like in the beginner's guide in the wiki:

127.0.0.1  yourhostname.domain.org   localhost.localdomain   localhost yourhostname

FWIW smile

so if  hostname is mm  "hello"

it would be

127.0.0.1 hello.domain.org localhost.localdomain localhost hello

right? : o

Offline

#7 2007-09-01 15:40:03

Eliteforce
Member
Registered: 2006-03-26
Posts: 56

Re: /etc/hosts correct format ?

i'd put something like this into the file:
127.0.0.1 localhost localhost.localdomain hostname hostname.localdomain

but i think that the localdomain stuff isn't needed at all.

Offline

#8 2007-09-01 16:35:35

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: /etc/hosts correct format ?

Eliteforce wrote:

i'd put something like this into the file:
127.0.0.1 localhost localhost.localdomain hostname hostname.localdomain

but i think that the localdomain stuff isn't needed at all.

Actually it is needed for program compatibility. Certain programs will lag when opening them if the localhost syntax is wrong. smile

Offline

#9 2007-09-01 16:38:09

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: /etc/hosts correct format ?

AlmaMater wrote:
Misfit138 wrote:

I experienced lag when loading webpages when I had separate entries for /etc/hosts. When I put all entries on the same line, everything works nicely. Like in the beginner's guide in the wiki:

127.0.0.1  yourhostname.domain.org   localhost.localdomain   localhost yourhostname

FWIW smile

so if  hostname is mm  "hello"

it would be

127.0.0.1 hello.domain.org localhost.localdomain localhost hello

right? : o

Yes. I suppose YMMV, but I have had 100% success with this syntax, gleaned from the beginner's guide and forum. smile

Offline

#10 2007-09-03 22:28:27

Kienja Kenobi
Member
Registered: 2007-08-17
Posts: 62

Re: /etc/hosts correct format ?

These are simple questions, but I have not found the answers anywhere. 

First, I can put anything I want for the hostname in rc.conf, right?  That is kind of shown here in this thread, but I want to make sure, because that seems odd to me. 

Next, what do I replace "localhost" and "localdomain" with?  Do literally leave them typed just as your examples show? 

Last, how can I tell if I have a static IP or a dynamic IP?  Does it have to do with the hardware I have or my Internet provider?

Offline

#11 2007-09-04 06:32:12

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: /etc/hosts correct format ?

You need the actual words "localhost" and "localhost.localdomain" - everything else is at the mercy of your imagination. smile

Offline

#12 2007-09-04 08:58:22

TreeMinds
Member
Registered: 2007-09-01
Posts: 35

Re: /etc/hosts correct format ?

I made it like this:
127.0.0.1    banana.ufo.org localhost.localdomain   localhost banana
10.0.0.2    banana.ufo.org                            banana

Offline

#13 2007-09-04 11:19:20

Eliteforce
Member
Registered: 2006-03-26
Posts: 56

Re: /etc/hosts correct format ?

so what does banana resolve to now? 127.0.0.1, 10.0.0.2 or both?

Offline

#14 2007-09-04 11:57:12

TreeMinds
Member
Registered: 2007-09-01
Posts: 35

Re: /etc/hosts correct format ?

I dont know man. Somewhere I saw that (if u have static ip do 2nd line with it)
What do u suggest maybe:
127.0.0.1  localhost.localdomain   localhost
10.0.0.2    banana.ufo.org            banana
?

Last edited by TreeMinds (2007-09-04 11:57:32)

Offline

#15 2007-09-04 15:00:44

dschrute
Member
From: NJ, USA
Registered: 2007-04-09
Posts: 183

Re: /etc/hosts correct format ?

TreeMinds wrote:

I dont know man. Somewhere I saw that (if u have static ip do 2nd line with it)
What do u suggest maybe:
127.0.0.1  localhost.localdomain   localhost
10.0.0.2    banana.ufo.org            banana
?

Typically if you have a dynamic IP you would want only the 127.0.0.1 line.  if you have a static IP you want to add the 2nd line.  So assuming 10.0.0.2 is your static IP, this is the correct format.
Also the last entry in the file is the one that will be resolved...So for example, appending banana to the 127.0.0.1 line, when you still have the 10.0.0.2 entry effectively does nothing.  banana will still resolve to 10.0.0.2

Offline

Board footer

Powered by FluxBB