localhost or LAN addresses in /etc/hosts
cl at isbd.net
Mon Dec 15 17:17:41 UTC 2008
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
> > 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
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.
More information about the ubuntu-users