On Wed, May 18, 2005 at 09:45:17AM -0600, Hans Fugal wrote:
> Here's one of those deep questions. What is the proper format for the
> loopback line in /etc/hosts? I've seen all of the following:

I'll put my /etc/hosts below.

> 
> ...
> 
> 127.0.0.1 localhost.localdomain localhost foo foo.example.com

Not good. The first two entries are fine. 

The foo entries should point to your network interface. The reason for
this is you may need to resolve your network interface some time when
DNS is unavailable, e.g. it's down, or you are debugging your network
setup and can't reach the name server.

How often do you ping your own interface? Not very, but almost all the
time it's when you're toubleshooting your network.

> 
> ...
> 
> 127.0.0.1 localhost localhost.localdomain
> 10.0.0.1 foo.example.com foo

Much better.

> 
> ...
> 
> 127.0.0.1 localhost
> 10.0.0.1 foo.example.com foo

Leaves out localhost.localdomain, which you may want to use.

> 
> ...
> 
> 127.0.0.1 localhost
> 127.0.0.1 foo.example.com foo

Effectively the same as the first example above.


> 
> ...
> 
> 127.0.0.1 localhost

Ignores your network interface. This means you depend on name
resolution for your network interface; see above.

> 
> ...
> 
> So what is best, and why? Specifically, is it best to put the hostname
> (foo) on the loopback IP address, or on the real IP address? 

The real one.

> If the latter, what if your box has several IP addresses?

Then it's pretty much dependent on your network. If a machine is
multihomed and a router, I'd point it to my upstream connection. If I
have several upstream connections, I'd pick the one most likely to
cause me problems.

Remember that a multi-homed machine can have multiple host names, and
therefore multiple FQDNs. I'd point each one to the appropriate interface.

Here is what I have:

--------------------------------------------------
# Time-stamp: <2004-12-29 16:35:01 root hosts>

# N.B. use the non-routable, private, experimental class C net
# provided for in RFCs 1597 and 1918. Available networks are:

#    Class  |  Networks
#      A    |  10.0.0.0
#      B    |  172.16.0.0  through 172.31.0.0
#      C    |  192.168.0.0 through 192.168.255.0

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
192.168.1.3     charlesc charlesc.localdomain
--------------------------------------------------

If I ever got around to it, I could change my network to use
charlescurley.com internally. (The outside world does not see my
network, as you have deduced from the network I use.) If I did that, I
would go with:

127.0.0.1       localhost.charlescurley.com localhost
192.168.1.3     charlesc charlesc.charlescurley.com


-- 

Charles Curley                  /"\    ASCII Ribbon Campaign
Looking for fine software       \ /    Respect for open standards
and/or writing?                  X     No HTML/RTF in email
http://www.charlescurley.com    / \    No M$ Word docs in email

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB

Attachment: pgpuQLfFEBUgP.pgp
Description: PGP signature

.===================================.
| This has been a P.L.U.G. mailing. |
|      Don't Fear the Penguin.      |
|  IRC: #utah at irc.freenode.net   |
`==================================='

Reply via email to