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

Re: /etc/hosts + resolvconf (was Re: associating names and addresses)



On Wed, Mar 26, 2008 at 12:22:41PM +1300, Chris Bannister wrote:
> 	root@box:~# less /etc/hosts
> 	127.0.0.1       box localhost
> 
> > Conclusion
> > Well now I see that the correct solution to 
> > the original problem was to leave /etc/hosts 
> > with the line 
> > 127.0.0.1 localhost.localdomain localhost
> > and install resolvconf.  Unfortunately, this 
> > was not recognized at the time and the message 
> > from Xfce was misleading.
> 
> 	root@box:~# apt-cache policy resolvconf
> 	resolvconf:
> 	  Installed: (none)
> 	[..]
> 
> So thats ok? But If resolvconf is installed then /etc/hosts should be:
> 
> 	127.0.0.1       localhost.localdomain localhost
> 
> Is that correct?

The way I look at it is thus:

If the box is stand-alone, not on any network, and you want to give it a
name other than "localhost", then just do:

127.0.0.1	localhost.localdomain localhost fred

	with "fred" in /etc/hostname.

If the box is stand-alone with dial-up ppp to the internet, just do the
same thing.

However, once you have a NIC and have an interface other than lo, then
assign the box's hostname to that NIC, e.g:

127.0.0.1	localhost.localdomain localhost
192.168.0.1	fred

And if there is any chance of expanding your network in the future, give
yourself a domain name now:
192.168.0.1	fred.myhome	fred

Having the resolvconf package is primarily useful if you have various
dynamic sources of DNS info.  I.e. you have ppp, you sometimes use
another local box or you sometimes access the internet with ethernet
(e.g. a laptop box that travels).

I haven't found any UNIX book that talks about the contents of
/etc/hosts on a box that isn't on a network.  I don's see a problem
putting the localhost in the 127.0.0.1 line; it means that you can 

$ ping fred

and ping the localhost.  More importantly, it helps if you, e.g.
misconfigure your MTA and it tries to do a DNS lookup before it sends
the mail to itself, it will find itself.

I hope this helps.

If you want more definitive UNIX networking, try "UNIX System
Administration Handbook".

Doug.


Reply to: