localhost or LAN addresses in /etc/hosts

Derek Broughton news at pointerstop.ca
Mon Dec 15 13:54:13 UTC 2008

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

More information about the ubuntu-users mailing list