localhost or LAN addresses in /etc/hosts
Derek Broughton
news at pointerstop.ca
Fri Dec 12 18:51:26 UTC 2008
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.
> 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.
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.
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"
--
derek
More information about the ubuntu-users
mailing list