localhost or LAN addresses in /etc/hosts

Chris G cl at isbd.net
Mon Dec 15 19:50:19 UTC 2008

On Mon, Dec 15, 2008 at 02:44:28PM -0400, Derek Broughton wrote:
> > 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.
> No, that's just the ONE place you have to do things.  In the time you've 
> been asking us how to do this with a piece of software that you had to 
> add to your system, I could have done the setup dozens of times on a 
> router.
... and, similarly, I could have done it by editing /etc/hosts.

> > I'm using dnsmasq to try and minimise that sort of hassle.
> How much hassle do you think you've minimized so far?
Lots!  The *only* thing I need to change ever is /etc/hosts on one
machine.  Just as easy (easier IMHO) as doing things via the web
(presumably) on a router *and* it gets backed up when I back up my

> > 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:-
> You HAVEN'T got it to work with /etc/hosts - specifically because you're 
> trying to do something you can't do.  
Who says - I seem to have it working fine now using dnsmasq and simple
names.  I just guessed that I *could* remove the entries I was
originally asking about and it all works OK.  It's what dnsmasq is
specifically designed to do as far as I understand it.

> >     Set the printer (for example) to have a fixed IP of
> > 
> >     Put "  printer" in /etc/hosts on *one* system which
> >     runs dnsmasq.
> Same on the router.  You don't even _have_ to have the MAC address.
> > 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.
> So do things the hard way, then, but you'd rather argue with everybody 
> who's telling you you simply _can't_ do it the way you want to.  Your 
> /etc/hosts can only have ONE (working) IP address for a single host.  

That's what my original question was about.  All I wanted to know was
whether I could remove the local host name from the and entries and leave it against the entry.  It
turns out that I *can* do this and everything works well with dnsmasq.

> And whether dnsmasq can handle hostnames without domains or not, you 
> can't _treat_ "isbd" in a dns lookup from a client with no search 
> domains set, the same as a hostname lookup in the local /etc/hosts.  
> They're doing different things, that just happen to resolve to the same 
> address when isbd _is_ your local host (and then only because local dns 
> lookup generally checks your /etc/hosts first).

My /etc/hosts now has:-       localhost.localdomain   localhost vigor 2820n home.isbd.net isbd 84-45-228-40.no-dns-yet.enta.net chris.isbd.net home maxine garage
    ... plus more lines.

If I say 'host isbd' on the garage system see what happens:-

    chris at garage:~$ host isbd
    isbd has address
    chris at garage:~$ 

The garage system has a default /etc/hosts, I've added nothing to it.

So it seems to me I'm getting exactly what I need, a DNS system that
gives me valid LAN addresses for local names.

Chris Green

More information about the ubuntu-users mailing list