localhost or LAN addresses in /etc/hosts
Chris G
cl at isbd.net
Fri Dec 12 20:30:04 UTC 2008
On Fri, Dec 12, 2008 at 02:51:26PM -0400, Derek Broughton wrote:
> Chris G wrote:
>
> > How does one decide whether to put a machine's name as a localhost
> > address or an actual LAN address in /etc/hosts?
> >
> > My ubuntu server machine's name is isbd, this appears in three places
> > in /etc/hosts at the moment:-
> >
> > 127.0.0.1 isbd localhost.localdomain localhost
> > 127.0.1.1 isbd
> >
> > 192.168.1.4 home.isbd.net isbd 84-45-228-40.no-dns-yet.enta.net
> > chris.isbd.net
> >
> > This is all very well until one runs something like dnsmasq and get
> > localhost addresses when asking for the address of isbd.
> >
> > I think the 127.0.1.1 is redundant and should be removed,
>
> I'd say you're just thoroughly misconfigured. You _can't_ have isbd be
> all three addresses. Personally, I don't think if you're running
> dnsmasq, isbd should be in there at all - _that's_ why you're running
> your own DNS.
>
dnsmasq uses the entries in /etc/hosts to provide information to other
machines on the LAN. Thus it *needs* an entry for isbd somewhere to
tell other machines what isbd's address is.
Without dnsmasq the addresses for isbd are all perfectly valid as far
as I understand it.
> > can I also
> > remove the isbd from the 127.0.0.1 line as well? Why does it get put
> > there, maybe it's there for use when the machine gets its IP via DHCP
> > and thus it isn't fixed.
>
> No. It's got nothing to do with DHCP. 127.0.0.1 and 127.0.1.1 are, for
> all intents, the same address (the address of your "lo" interface - any address on the 127 subnet is masked to 127.0.0.0). The advantage of
> using different numbers is that something like Apache's virtual hosts can
> then see a different IP for each hostname - even though to the network,
> it's the same.
>
Yes, I realise that, I'm not quite sure why there are two but (without
dnsmasq) it doesn't actuall matter.
> The 192.168.1.4, address _is_ likely DHCP related - at least, it was
> probably assigned by your router, and if so IT SHOULDN"T EVEN APPEAR in
> /etc/hosts.
>
No, I have static addresses assigned so it's correct. Apart from
anything else how, otherwise, would one access things such as printers
(my 192.168.1.44 hp7310 for example), they have to be fixed addresses.
> Now, the real question is what do you mean by "asking for the address of
> isbd"? isbd is, by definition, your local machine, therefore a DNS
> lookup should always give you 127.x.x.x. If you mean that you want the
> address of the host "isbd" on your local network, then the name is
> probably something like "isbd.isbd.net"
I'm talking about finding the address of "isbd" from another machine on
the LAN. That's what dnsmasq is for, if another machine on the LAN
asks for the address of "isbd" dnsmasq will tell it "192.168.1.4".
127.x.x.x is only the right address for "isbd" when the question is
asked from "isbd".
--
Chris Green
More information about the ubuntu-users
mailing list