[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How does host lookup work



On Tue, Mar 24, 2009 at 06:40:41PM +0000, Alan Chandler wrote:
> On Monday 23 Mar 2009, Alex Samad wrote:
> > On Mon, Mar 23, 2009 at 09:28:27PM +0000, Alan Chandler wrote:
> > > I am extremely confused about host lookup works now that avahi
> > > daemon has been added into the equation.
> > >
> > > my /etc/nsswitch.conf file has this in it for the host entry
> > >
> > > hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
> > >
> > > But as much as I google, I can find absolutely no explanation of
> > > what mdns4_minimal does.
> >
> > its part of libnss-mdns
> > /usr/share/doc/libnss-mdns/README.Debian
> > https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/94940 (of
> > interest)
> 
> But neither of these two links explain what mdnd4_minimal does. 
at a guess they are providing nss linkages to mdns, so pam calls
libnss-mdns_minimal

> > > In particular - if one does a host lookup and its not found in
> > > files (presumably /etc/hosts) and not found by mdns4_minimal, does
> > > the "[NOTFOUND=return]" stop the lookup process from using the dns.
> > > (It clearly doesn't - so presumably mdns4_minimal does something
> > > else)
> 
> I still do not understand [NOTFOUND=return].
> 
> My reading of the manual is that it stops a failed lookup moving on to 
> the subsequent entries.  How do the dns entry and the mdns4 entry ever 
> get used?

from man nsswitch.conf, it say about the same thing, so if you have mdns
(or mdns_minimal) installed it takes over all dns resolution for you

success - means you have resolution and returns -  goes no further
notfound - means mds worked but did not find a record and thus returns
unavail - this is the only time it will make it past


> 
> [I know the DO get used, so my understanding is obviously WRONG.  I want 
> to find out what the correct interpretation of that is] 

from the README.html

libnss_mdns{4,6,}_minimal.so (new in version 0.8) is mostly identical to
the           
   versions without _minimal. However, they differ in one way. The
minimal versions       
   will always deny to resolve host names that don't end in .local or
addresses that      
   aren't in the range 169.254.x.x (the range used by
IPV4LL/APIPA/RFC3927.)



> 
> ...
> > > I will want to use it to develop some simple
> > > javascript/php/html/css web applications - and therefore will want
> > > to run apache web server. Ideally I would like a number of separate
> > > virtual hosts, for each separate application but
> > >
> > > a) When I am disconnected from the network I still need to see the
> > > host names (so I assume I use /etc/hosts to give aliases to
> > > localhost?)
> >
> > sounds good, although there are problems when you use 127.0.0.1
> 
> You say problems, what problems?
can't remember at this time. came about when machine names where added
to /etc/hosts ast 127.0.0.1 <name> localhost localhost.localdomain


> 
> >
> > > b) When I am connected to the local home network I want to have
> > > other people see these virtual hosts so that I can test some
> > > multiuser aspects of the applications.  In this case, I could
> > > either use avahi to publish these names (although at the moment I
> > > can't quite work out how - it seems only to publish a single host
> > > name derived from the /etc/hostname), or make sure the names are
> > > properly identified in my local dns (I can allocate the IP address
> > > based on the mac address of the laptop thereby ensuring it always
> > > has the same one)
> >
> > do the names need to be dynamic, why not make then static such that
> > when you are not there the web page times out!
> 
> I need them to refer to a valid ip address of the laptop - but one that 
> is also valid when the laptop is disconnected from the network. 
> 
> So I "think" a plan like this might work
> 
> I set up my dbcp server at home to recognise the MAC address(es) of my 
> laptop and to allocate a fixed ip address [say 192.168.0.26] to the 
> laptop (this allows me also to connect the laptop to other networks 
> away from home and obtain an ip address) 
> 
> My home network is in the .home domain.  I then add green.home and 
> blue.home to my dns server, so any reference by a computer on the home 
> network to green.home or blue.home get the ipaddress 192.168.0.26
> 
> I then add the following lines to /etc/hosts (over and above what debian 
> adds)
> 
> 127.0.2.1	green.home green
> 127.0.3.1	blue.home blue
> 
> This ensures that any references in the software internal sees addresses 
> for green.home and blue.home as the local machine regardless of whether 
> its connected to the network or not.
> 
> In apache, I set up named virtual hosts like this
> 
> <virtualhost *:80 >
>       ServerName green.home
>       DocumentRoot /home/alan/web-dev/green
> </virtualhost>
> <virtualhost *:80 >
>       ServerName blue.home
>       DocumentRoot /home/alan/wev-dev/blue
> </virtualhost>
> 
> Tnen when I am not on my home network I can still point my browser at 
> http://green.home, or http://blue.home to test out my applications
> 
> BUT when I am at home and not travelling, I can also point my desktop's 
> brower at http://green.home or http://blue.home and get it to also see 
> the web sites.

sounds okay

> 
> -- 
> Alan Chandler
> http://www.chandlerfamily.org.uk
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 

-- 
"Now, there are some who would like to rewrite history--revisionist historians is what I like to call them."

	- George W. Bush
06/16/2003
Elizabeth, NJ

Attachment: signature.asc
Description: Digital signature


Reply to: