[ILUG] Resolvers and DNS

Colm Buckley colm at tuatha.org
Tue Apr 27 11:18:04 IST 1999


> i think that a dot after the TLD is implicit, and signifies the root domain.
> i'll check up in the o'reilly book when i get home.

Yes.  This is a DNS artifact.

A domain name without a trailing dot, technically, isn't
fully-qualified, and the resolver (library which converts names into IP
addresses) is at liberty to try to figure out what you mean.  Usually,
there's some sort of heuristic like "if it has more than one dot in it,
assume it's a fully-qualified name and add a trailing dot, otherwise try
appending the current domain, or domain from the search path".  These
are usually configurable using resolv.conf on systems (like Linux) with
the standard resolver.

Example - here's a resolv.conf similar to my one:

nameserver 127.0.0.1
domain tuatha.cs.tcd.ie
search tuatha.cs.tcd.ie tuatha.org cs.tcd.ie tcd.ie
options nodots:2

Given a host "ogma" to search for, it counts the dots (zero), and checks
that against the value of "nodots" (2).  As it's smaller, it won't try
"ogma." as an absolute name first, rather it takes the paths in the
"search" option one by one, and tries them - so, in order, it would
attempt to resolve:

ogma.tuatha.cs.tcd.ie.   -- this succeeds, so the others aren't tried.
ogma.tuatha.org.
ogma.cs.tcd.ie.
ogma.tcd.ie.
ogma.

Given "salmon.maths", the same principle would apply.  It contains one
dot, which is less than two, so it applies the search paths again:

salmon.maths.tuatha.cs.tcd.ie.
salmon.maths.tuatha.org.
salmon.maths.cs.tcd.ie.
salmon.maths.tcd.ie.     -- this succeeds
salmon.maths.

Given "www.ibm.com", however, the number of dots is 2, which is *not*
smaller than the value of the "nodots" option, so it tries the absolute
query first:

www.ibm.com.             -- success!
www.ibm.com.tuatha.cs.tcd.ie.
www.ibm.com.tuatha.org.
www.ibm.com.cs.tcd.ie.
www.ibm.com.tcd.ie.

In most cases, the default value of "nodots" (1) is suitable - it means
that a hostname with no dots in it at all is checked against the search
path first (usually, the local domain), and a hostname with dots is
assumed to be an absolute (fully-qualified) name, and is tried as such
first.

There's a further twist to the resolver thing, in that most systems can
tweak its operation using the nsswitch.conf file - the "hosts" entry in
this file tells the resolver the order in which methods are tried.  EG :
mine contains:

hosts:          files dns nis

... which means, "When looking up a hostname, first try for an exact
match in the /etc/hosts file.  If that fails, try the DNS approach (as
outlined above).  If that fails, try looking it up in the NIS (YP)
'hosts.byname' map."

This has been your unscheduled braindump.  We now return you to regular
programming...

           Colm

-- 
Colm Buckley B.A. B.F. # colm at tuatha.org colm.buckley at tcd.ie colm at computer.org
Department of Computer Science      # +353 87 2469146 # whois cb3765
Trinity College, Dublin 2, Ireland. # http://www.tuatha.org/~colm/
Friends may come and go, but enemies tend to accumulate.




More information about the ILUG mailing list