localhost or LAN addresses in /etc/hosts

classic Classic list List threaded Threaded
55 messages Options
123
Reply | Threaded
Open this post in threaded view
|

localhost or LAN addresses in /etc/hosts

Chris Green
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, 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.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Derek Broughton-2
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Nils Kassube-2
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Derek Broughton-2
In reply to this post by Chris Green
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
In reply to this post by Nils Kassube-2
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

NoOp-4
In reply to this post by Chris Green
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Florian Diesch
In reply to this post by Chris Green
Chris G <[hidden email]> 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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Nils Kassube-2
In reply to this post by Chris Green
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
In reply to this post by Derek Broughton-2
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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
In reply to this post by Florian Diesch
On Sat, Dec 13, 2008 at 02:04:42AM +0100, Florian Diesch wrote:

> Chris G <[hidden email]> 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
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
In reply to this post by Nils Kassube-2
On Sat, Dec 13, 2008 at 07:35:24AM +0100, Nils Kassube wrote:

> 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.
>
You're right of course, but a little extra configuration of dnsmasq is
required to tell it where the upstream DNS is as, by default, it uses
/etc/resolv.conf.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Carl Friis-Hansen-2
In reply to this post by Chris Green
Chris G wrote:
<snip>

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

In one of my LANs I am using Tomato Linux software on a WRT54g. On this
LAN the router finds the machine names by  itself. Wouldn't the machine
names be broadcast to the router?

--
       +---------------------------------+-------------------+
       | Carl Friis-Hansen               | Fiskeryd Nybygget |
       | http://computingconfidence.com/ | 341 91  Ljungby   |
       | Phone: +46 (0)372 15033         | Sweden            |
       +---------------------------------+-------------------+


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Joep L. Blom
In reply to this post by Chris Green
Chris G schreef:

> On Sat, Dec 13, 2008 at 07:35:24AM +0100, Nils Kassube wrote:
>> 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.
>>
> You're right of course, but a little extra configuration of dnsmasq is
> required to tell it where the upstream DNS is as, by default, it uses
> /etc/resolv.conf.
>
chrid,
I use dnsmasq on my firewall (LEAF) as DNS- and DHCP-server. Look into
the file dnsmasq.leases DNSmasq stores the given addresses together with
the systemname and MAC-addresses of the systems on the network.
With respect to printers, address them by name (if you don't know it you
can lookup the name in dnsmasq.leases).
In my firewall dnsmasq.leases is stored in /var/lib/misc but it maybe
well elesewhere opn your system.
Hope this helps,
Joep

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Derek Broughton-2
In reply to this post by Chris Green
Chris G wrote:

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

The usual way is by the machine asking for DHCP to send its name, and
the router sends back an IP - and updates its local DNS.  This is not
implemented in every router, but it's _really_ common.

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

There wouldn't be much point, since the router's DNS is mainly there to
map the addresses assigned by DHCP.  

>> > 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?  :-)  ...

Logically, none.  But you can get this effect with the DHCP on any router
I've used.

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

That's the point - it can't change, but that doesn't mean you need to go
to this trouble with static addresses.  Use the DHCP on your router,
tell it to always assign 192.168.1.44 to the MAC address of your hp7310
printer, and then even if you disconnect and reconnect, your printer
will always have the same address - and it _should_ be in your router's
DNS, too.

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

Yes, but the "simple" name is _always_ automatically suffixed with the
search domains.

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

You don't _have_ easy configuration as long as you're doing it manually.  
"Use the Force" - let the router do the work.
--
derek


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Derek Broughton-2
In reply to this post by Chris Green
Chris G wrote:

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

Why not?  It can use 127.0.0.1, too.
--
derek


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
In reply to this post by Derek Broughton-2
On Mon, Dec 15, 2008 at 09:54:13AM -0400, Derek Broughton wrote:

> Chris G wrote:
>
> > 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.
>
> The usual way is by the machine asking for DHCP to send its name, and
> the router sends back an IP - and updates its local DNS.  This is not
> implemented in every router, but it's _really_ common.
>
So the *router* decides what the machine's name is?

> > 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).
>
> There wouldn't be much point, since the router's DNS is mainly there to
> map the addresses assigned by DHCP.  
>
> >> > 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?  :-)  ...
>
> Logically, none.  But you can get this effect with the DHCP on any router
> I've used.
>
I really don't understand this.  I have two printers on my network,
one is an HP7310 which has its own network interface the other is a
laser printer which is accessed via an Axis print server.  So, if the
router is providing DHCP and DNS services how does it get to know
about the printers?  Presumably when I turn the Axis print server on
it gets an IP address from the router but how does the router know
that it's a printer and/or give it a useful name that I will know
about and be able to use?


> > 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?
>
> That's the point - it can't change, but that doesn't mean you need to go
> to this trouble with static addresses.  Use the DHCP on your router,
> tell it to always assign 192.168.1.44 to the MAC address of your hp7310
> printer, and then even if you disconnect and reconnect, your printer
> will always have the same address - and it _should_ be in your router's
> DNS, too.
>
How is that any easier than simply giving the printer a static IP?  I
have to faff about in the router's configuration to tell it to
associate the MAC addres with the printer, that's just *another* place
I have to do things.  I'm using dnsmasq to try and minimise that sort
of hassle.


> > 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.
>
> Yes, but the "simple" name is _always_ automatically suffixed with the
> search domains.
>
> >> > 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.  
>
> You don't _have_ easy configuration as long as you're doing it manually.  
> "Use the Force" - let the router do the work.

How is setting up MAC addresses to match devices in the router any
easier than editing /etc/hosts?  That's where I really don't follow
what you're advising.  As it is all I do is:-

    Set the printer (for example) to have a fixed IP of 192.168.1.40

    Put "192.168.1.40  printer" in /etc/hosts on *one* system which
    runs dnsmasq.

The printer never changes once its IP address is set, computers may
come and computers may go but that only needs doing once.  Similarly
if I change the computer where dnsmasq is running all I need to do is
copy /etc/hosts and everything is done.

The alternative of configuring the router doesn't seem to win me much
and means I have configuration information I can't back up easily.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Bart Silverstrim
Chris G wrote:

> On Mon, Dec 15, 2008 at 09:54:13AM -0400, Derek Broughton wrote:
>> Chris G wrote:
>>
>>> 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.
>> The usual way is by the machine asking for DHCP to send its name, and
>> the router sends back an IP - and updates its local DNS.  This is not
>> implemented in every router, but it's _really_ common.
>>
> So the *router* decides what the machine's name is?

The DNS server ties a name to an IP. On simple router multifunction
devices, if the DHCP and DNS server are tied together, they can be the
one to determine the name giving to the IP address.

You can have a device call itself whatever it wants...as far as the
network is concerned, other devices will consult the DNS server to find
the name, just like you can call yourself Huggybears but Uncle Sam calls
you by whatever you have on your birth certificate.

Okay, silly example, but you get the gist of it.

>>>>> 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?  :-)  ...
>> Logically, none.  But you can get this effect with the DHCP on any router
>> I've used.
>>
> I really don't understand this.  I have two printers on my network,
> one is an HP7310 which has its own network interface the other is a
> laser printer which is accessed via an Axis print server.  So, if the
> router is providing DHCP and DNS services how does it get to know
> about the printers?  Presumably when I turn the Axis print server on
> it gets an IP address from the router but how does the router know
> that it's a printer and/or give it a useful name that I will know
> about and be able to use?

If I'm reading what you're being explained in the thread correctly...

If you have devices looking for your printer *by name*, then it doesn't
matter what their name is if assigned reliably via DHCP and updated in
DNS. You can name it Print-1 and no matter what the IP, if the DNS is
updated correctly each time the printer gets the IP from the DHCP server
you have the ability to find it by asking the network for Print-1.

I personally don't do this. I have network printers on a static IP and
set them up on the my systems with a static IP, so I don't need to worry
about DNS records or DHCP working properly for devices I don't move around.

My printers are set to an IP block that isn't handed out by the DHCP
server...I set aside a small number of IP's for printers that are
excluded from DHCP and then keep them as you sound like you did, static
on the printing device.

The only things on my network DHCP'd are computers.

If we're talking home routers, those SOHO devices from
Staples/newegg/whatever, chances are the @#$% things will die in less
than a year or two anyway so the less I rely on them for configuring my
network the less hassle I have replacing it.

> How is setting up MAC addresses to match devices in the router any
> easier than editing /etc/hosts?  That's where I really don't follow
> what you're advising.  As it is all I do is:-

Because you'd have to edit /etc/hosts on multiple machines if you have
multiple machines to administer, or if you have a mixed environment in
your home. It's a lot easier to not worry about editing files every time
you have a visitor or new computer and centralize management when you
can, but you have to balance it for your environment and preferences. I
also balance this out with the experiences where if this isn't a
thousand-dollar Cisco device we're talking about then I've had them
periodically fail on me for giggles.

I got to the point where I bought a separate switch and WAP because the
combo devices failed on me often enough to @#$!@ #!@#$#$%%%

-Bart

-Bart

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Chris Green
On Mon, Dec 15, 2008 at 12:36:36PM -0500, Bart Silverstrim wrote:

> Chris G wrote:
> > On Mon, Dec 15, 2008 at 09:54:13AM -0400, Derek Broughton wrote:
> >> Chris G wrote:
> >>
> > I really don't understand this.  I have two printers on my network,
> > one is an HP7310 which has its own network interface the other is a
> > laser printer which is accessed via an Axis print server.  So, if the
> > router is providing DHCP and DNS services how does it get to know
> > about the printers?  Presumably when I turn the Axis print server on
> > it gets an IP address from the router but how does the router know
> > that it's a printer and/or give it a useful name that I will know
> > about and be able to use?
>
> If I'm reading what you're being explained in the thread correctly...
>
> If you have devices looking for your printer *by name*, then it doesn't
> matter what their name is if assigned reliably via DHCP and updated in
> DNS. You can name it Print-1 and no matter what the IP, if the DNS is
> updated correctly each time the printer gets the IP from the DHCP server
> you have the ability to find it by asking the network for Print-1.
>
Where/what do I tell that the printer is called Print-1, this is the
bit that's not clear to me.  Are you saying that I should give it this
name in teh router configuration?

> I personally don't do this. I have network printers on a static IP and
> set them up on the my systems with a static IP, so I don't need to worry
> about DNS records or DHCP working properly for devices I don't move around.
>
Exactly!  Much more sensible and easier IMHO, that's why I do it this
way too. :-)


> My printers are set to an IP block that isn't handed out by the DHCP
> server...I set aside a small number of IP's for printers that are
> excluded from DHCP and then keep them as you sound like you did, static
> on the printing device.
>
> The only things on my network DHCP'd are computers.
>
> If we're talking home routers, those SOHO devices from
> Staples/newegg/whatever, chances are the @#$% things will die in less
> than a year or two anyway so the less I rely on them for configuring my
> network the less hassle I have replacing it.
>
> > How is setting up MAC addresses to match devices in the router any
> > easier than editing /etc/hosts?  That's where I really don't follow
> > what you're advising.  As it is all I do is:-
>
> Because you'd have to edit /etc/hosts on multiple machines if you have
> multiple machines to administer, or if you have a mixed environment in

Er, no, this is where we came in!  I'm using dnsmasq on *one* machine
in the LAN and that means I only have to edit *one* /etc/hosts and
dnsmasq tells other machines on the network the contents of that one
/etc/hosts via DNS.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: localhost or LAN addresses in /etc/hosts

Bart Silverstrim
Chris G wrote:

> On Mon, Dec 15, 2008 at 12:36:36PM -0500, Bart Silverstrim wrote:
>> Chris G wrote:
>>> On Mon, Dec 15, 2008 at 09:54:13AM -0400, Derek Broughton wrote:
>>>> Chris G wrote:
>>>>
>>> I really don't understand this.  I have two printers on my network,
>>> one is an HP7310 which has its own network interface the other is a
>>> laser printer which is accessed via an Axis print server.  So, if the
>>> router is providing DHCP and DNS services how does it get to know
>>> about the printers?  Presumably when I turn the Axis print server on
>>> it gets an IP address from the router but how does the router know
>>> that it's a printer and/or give it a useful name that I will know
>>> about and be able to use?
>> If I'm reading what you're being explained in the thread correctly...
>>
>> If you have devices looking for your printer *by name*, then it doesn't
>> matter what their name is if assigned reliably via DHCP and updated in
>> DNS. You can name it Print-1 and no matter what the IP, if the DNS is
>> updated correctly each time the printer gets the IP from the DHCP server
>> you have the ability to find it by asking the network for Print-1.
>>
> Where/what do I tell that the printer is called Print-1, this is the
> bit that's not clear to me.  Are you saying that I should give it this
> name in teh router configuration?

If your router has the integrated DHCP and DNS servers, and the
functions to tie a MAC address to a DHCP assignment, you'd do it there
normally.

>> I personally don't do this. I have network printers on a static IP and
>> set them up on the my systems with a static IP, so I don't need to worry
>> about DNS records or DHCP working properly for devices I don't move around.
>>
> Exactly!  Much more sensible and easier IMHO, that's why I do it this
> way too. :-)

On small networks it doesn't hurt. It comes down to what you want to do
to manage it and your environment.

>> Because you'd have to edit /etc/hosts on multiple machines if you have
>> multiple machines to administer, or if you have a mixed environment in
>
> Er, no, this is where we came in!  I'm using dnsmasq on *one* machine
> in the LAN and that means I only have to edit *one* /etc/hosts and
> dnsmasq tells other machines on the network the contents of that one
> /etc/hosts via DNS.

Just answering why you'd do it or one reason why you'd do it that way...

There are other things that you factor in but I don't know your
environment or anything like that. But again it comes down to
experiences and familiarity, especially for small networks. It's like
asking why anyone needs Active Directory. I hate it. But in our
environment, 98% Windows based, it's almost prerequisite.

At home I have three Mac notebooks, one Mac desktop, an Asus EEE, a
Linux workstation, one Windows system, and a gaggle of virtual testbeds.
Active Directory would be silly to use.



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
123