FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-12-2008, 05:51 PM
Derek Broughton
 
Default localhost or LAN addresses in /etc/hosts

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


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2008, 07:30 PM
Chris G
 
Default localhost or LAN addresses in /etc/hosts

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

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2008, 08:17 PM
Nils Kassube
 
Default localhost or LAN addresses in /etc/hosts

Chris G wrote:
> 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.

Dnsmasq _can_ use the entries from "/etc/hosts" but it can also use
entries from a separate file e.g. "/etc/hosts.dnsmasq" (I think that's
the filename proposed in the config file). I would suggest you
use "/etc/hosts" only for the localhost entry and "/etc/hosts.dnsmasq"
for everything else. Then the resolver asks dnsmasq for everything except
localhost.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2008, 08:22 PM
Derek Broughton
 
Default localhost or LAN addresses in /etc/hosts

Chris G wrote:

> On Fri, Dec 12, 2008 at 02:51:26PM -0400, Derek Broughton wrote:

>> 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.

"somewhere". It's a long time since I had a configuration using dnsmasq,
but I thought it would use the upstream dns, so if your router is already
doing it, it could get it from there.

> Without dnsmasq the addresses for isbd are all perfectly valid as far
> as I understand it.

They're "valid" - but you can _still_ only get one result returned, and
I'm not even sure you can guarantee that it will be any specific value
from /etc/hosts. So you do a DNS lookup _from_ your machine and it
doesn't matter whether your result is 127.0.0.1 or 127.0.1.1 or
192.168.whatever, because those are all the addresses of interfaces on
your machine.

> Yes, I realise that, I'm not quite sure why there are two but (without
> dnsmasq) it doesn't actuall matter.

Historical. All other Debian-based distros, afaik, put your local machine name, along with "localhost", on 127.0.0.1. Ubuntu, for good and logical reasons, decided to put it on 127.0.1.1 (fairly recently - gutsy, I think).

> 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.

No they don't, they just have to not change as long as they're on the
network.

>> 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".

Well, no, it shouldn't. It _should_ specify a domain.

> 127.x.x.x is only the right address for "isbd" when the question is
> asked from "isbd".

Any other client doing a lookup should be taking the name "isbd" and
appending its "search domain" and finding the address that way. If, from
your example the search domain is "isbd.net" then dnsmasq should be
returning the correct values for "chris" and "home".
--
derek


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2008, 08:31 PM
Chris G
 
Default localhost or LAN addresses in /etc/hosts

On Fri, Dec 12, 2008 at 10:17:53PM +0100, Nils Kassube wrote:
> Chris G wrote:
> > 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.
>
> Dnsmasq _can_ use the entries from "/etc/hosts" but it can also use
> entries from a separate file e.g. "/etc/hosts.dnsmasq" (I think that's
> the filename proposed in the config file). I would suggest you
> use "/etc/hosts" only for the localhost entry and "/etc/hosts.dnsmasq"
> for everything else. Then the resolver asks dnsmasq for everything except
> localhost.
>
Then how does the machine where dnsmasq is running (192.168.1.4) get local
addresses? The other machines on the LAN use 192.168.1.4 for DNS and
that's fine with a file such as /etc/hosts.dnsmasq but 192.168.1.4
can't use 192.168.1.4 as it's DNS can it?

--
Chris Green

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2008, 08:58 PM
NoOp
 
Default localhost or LAN addresses in /etc/hosts

On 12/12/2008 10:16 AM, 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

Modify to:

127.0.0.1 localhost isbd.<localdomain>
127.0.1.1 isbd

Note: you can remove '<localdomain> if you have no local windows
network domain (MSHOME, WORKGOUP etc). Then:

127.0.0.1 localhost isbd
127.0.1.1 isbd

The '127.0.0.1 localhost isbd' rather than just '127.0.0.1 localhost' is
useful if you run samba etc. I've no idea about the rest (dnsmasq).






--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-13-2008, 12:04 AM
Florian Diesch
 
Default localhost or LAN addresses in /etc/hosts

Chris G <cl@isbd.net> 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

Having multiple IP addresses for one name in /etc/hosts is usually a bad idea.


> I think the 127.0.1.1 is redundant and should be removed, can I also
> remove the isbd from the 127.0.0.1 line as well?

Think about what you want 'isbd' to resolve to.

Usually you want to have a FQDN for a name, too, so most likely the
127.0.1.1 isn't what you want.



Florian
--
<http://www.florian-diesch.de/>
-----------------------------------------------------------------------
** Hi! I'm a signature virus! Copy me into your signature, please! **
-----------------------------------------------------------------------

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-13-2008, 05:35 AM
Nils Kassube
 
Default localhost or LAN addresses in /etc/hosts

Chris G wrote:
> On Fri, Dec 12, 2008 at 10:17:53PM +0100, Nils Kassube wrote:
> > Chris G wrote:
> > > 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.
> >
> > Dnsmasq _can_ use the entries from "/etc/hosts" but it can also use
> > entries from a separate file e.g. "/etc/hosts.dnsmasq" (I think
> > that's the filename proposed in the config file). I would suggest you
> > use "/etc/hosts" only for the localhost entry and
> > "/etc/hosts.dnsmasq" for everything else. Then the resolver asks
> > dnsmasq for everything except localhost.
>
> Then how does the machine where dnsmasq is running (192.168.1.4) get
> local addresses? The other machines on the LAN use 192.168.1.4 for DNS
> and that's fine with a file such as /etc/hosts.dnsmasq but 192.168.1.4
> can't use 192.168.1.4 as it's DNS can it?

Yes it can. Or you can use 127.0.0.1 if you prefer.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-13-2008, 09:38 AM
Chris G
 
Default localhost or LAN addresses in /etc/hosts

On Fri, Dec 12, 2008 at 05:22:34PM -0400, Derek Broughton wrote:
> Chris G wrote:
>
> > On Fri, Dec 12, 2008 at 02:51:26PM -0400, Derek Broughton wrote:
>
> >> 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.
>
> "somewhere". It's a long time since I had a configuration using dnsmasq,
> but I thought it would use the upstream dns, so if your router is already
> doing it, it could get it from there.
>
The whole point is to make things easy to configure, my router
certainly *doesn't* know the names/addresses of machines on my LAN and
I don't really see how it could. Of course dnsmasq does use the
upstream DNS for addresses it doesn't know but the upstream DNS is
currently my ISP's DNS. The router has both DHCP and DNS turned off
(you can't switch only one off).


> > Without dnsmasq the addresses for isbd are all perfectly valid as far
> > as I understand it.
>
> They're "valid" - but you can _still_ only get one result returned, and
> I'm not even sure you can guarantee that it will be any specific value
> from /etc/hosts. So you do a DNS lookup _from_ your machine and it
> doesn't matter whether your result is 127.0.0.1 or 127.0.1.1 or
> 192.168.whatever, because those are all the addresses of interfaces on
> your machine.
>
Yes, which work from the machine itself but only 192.168.1.4 will work
for other machines on the LAN so that's the address I want dnsmasq to use.


> > Yes, I realise that, I'm not quite sure why there are two but (without
> > dnsmasq) it doesn't actuall matter.
>
> Historical. All other Debian-based distros, afaik, put your local machine
name, along with "localhost", on 127.0.0.1. Ubuntu, for good and logical
reasons, decided to put it on 127.0.1.1 (fairly recently - gutsy, I think).
>
> > 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.
>
> No they don't, they just have to not change as long as they're on the
> network.
>
?? So what's the difference? :-) ... and, if they did change when,
for example, a printer was turned off and then on again (as it might
when using DHCP) how would the rest of the system know the printer's
IP address?


> >> 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".
>
> Well, no, it shouldn't. It _should_ specify a domain.
>
I'm sure I've read somewhere (can't find it now) that dnsmasq
specifically works for 'simple' names for machines on a LAN with
private addresses.

> > 127.x.x.x is only the right address for "isbd" when the question is
> > asked from "isbd".
>
> Any other client doing a lookup should be taking the name "isbd" and
> appending its "search domain" and finding the address that way. If, from
> your example the search domain is "isbd.net" then dnsmasq should be
> returning the correct values for "chris" and "home".

That spoils the easy configuration though, I need to go round to every
machine and tell it what its "search domain" is. The whole (well the
major) reason for using dnsmasq is so that I can do eveything on the
one machine.

--
Chris Green

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-13-2008, 09:42 AM
Chris G
 
Default localhost or LAN addresses in /etc/hosts

On Sat, Dec 13, 2008 at 02:04:42AM +0100, Florian Diesch wrote:
> Chris G <cl@isbd.net> 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
>
> Having multiple IP addresses for one name in /etc/hosts is usually a bad idea.
>
>
> > I think the 127.0.1.1 is redundant and should be removed, can I also
> > remove the isbd from the 127.0.0.1 line as well?
>
> Think about what you want 'isbd' to resolve to.
>
> Usually you want to have a FQDN for a name, too, so most likely the
> 127.0.1.1 isn't what you want.
>
The issue is that *I* didn't put the 127.0.0.1 or 127.0.1.1 entries in
/etc/hosts, the ubuntu installation process put them there. The
machine "isbd" is set up with a static IP of 192.168.1.4 and I added
that entry.

What I'm asking is whether removing the 127.0.0.1 and 127.0.1.1
entries for isbd will break anything. If I can remove those entries
without any problems then dnsmasq will do what I want and tell the
rest of my LAN that "isbd" is 192.168.1.4.

--
Chris Green

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 11:50 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org