9fans archive / 2008 / 09 / 150 /    prev next

From: erik quanstrom <quanstro@qua...>
Subject: Re: [9fans] dnsquery or search
Date: Thu, 18 Sep 2008 07:36:01 -0400

> I see that ndb/dnsquery returns correct information on my system, but
> I noticed that there is not a default domainname, like on linux, in /
> etc/resolv.conf we set the "search domainname" ... is there a similar
> setting in plan9

plan 9 dns tries to look up unrooted (no ".") names in the local databases.
first success wins.

here's the algorithm from /sys/src/cmd/ndb/dnresolve.c

	/*
	 *  hack for systems that don't have resolve search
	 *  lists.  Just look up the simple name in the database.
	 */
	if(!rooted && strchr(name, '.') == nil){
		rp = nil;
		drp = domainlist(class);
		for(nrp = drp; rp == nil && nrp != nil; nrp = nrp->next){
			snprint(nname, sizeof nname, "%s.%s", name,
				nrp->ptr->name);
			rp = dnresolve(nname, class, type, req, cn, depth+1,
				recurse, rooted, status);
			rrfreelist(rrremneg(&rp));
		}
		if(drp != nil)
			rrfreelist(drp);
		procsetname(procname);
		free(procname);
		return rp;
	}

- erik