Subject: Question about getnetbyname()
To: None <current-users@NetBSD.ORG>
From: Dave Huang <>
List: current-users
Date: 07/24/1997 21:27:54
Hiyas... I've got a question about the getnetbyname() call... the
manpage for it implies that it only searches the /etc/networks file.
In actuality, it tries to do nameserver queries. Strange nameserver
queries. And it doesn't seem to respect the "lookup file bind" I have
in my /etc/resolv.conf. It asks DNS first, then tries /etc/networks.

Lines 281 and 282 of libc/net/getnetnamadr.c are:
	strcpy(&qbuf[0], net);
	anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf));

net is the network name passed in as getnetbyname's argument. So why
the heck is it asking for PTR records? That's just, like, weird :)

Here's a tcpdump of the results of calling getnetbyname("3com-net"). is the domain name I made up for my little network, sloth
is the name server, dahan is the machine that calls getnetbyname.
/etc/resolv.conf on dahan has "lookup file bind" and "search"

21:14:09.307087 > 6698+ PTR? (39)
21:14:09.936725 > 6698 NXDomain* 0/1/0 (99)
21:14:09.937952 > 6699+ PTR? (34)
21:14:10.592538 > 6699 NXDomain* 0/1/0 (103)
21:14:10.593631 > 6700+ PTR? 3com-net. (26)
21:14:10.619418 > 6700 NXDomain* 0/1/0 (99)

The call eventually works, finding the entry for 3com-net in dahan's
/etc/networks file, but the thing that annoys me is that when it does
the DNS query for, it makes sloth dialout to my ISP
to ask some real nameservers.

So, is this a bug, or am I missing something?

I'm running with July 23 libraries, binaries, everything...

BTW, what's this, at line 288 of getnetnamadr.c?

		if (errno == ECONNREFUSED)
			return (_getnetbyname(net));
		return (_getnetbyname(net));

Name: Dave Huang     |   Mammal, mammal / their names are called /
INet:   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 21 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++