Subject: Question about getnetbyname()
To: None <current-users@NetBSD.ORG>
From: Dave Huang <firstname.lastname@example.org>
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:
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").
metonymy.com 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 dahan.metonymy.com.1081 > sloth.metonymy.com.domain: 6698+ PTR? 3com-net.metonymy.com. (39)
21:14:09.936725 sloth.metonymy.com.domain > dahan.metonymy.com.1081: 6698 NXDomain* 0/1/0 (99)
21:14:09.937952 dahan.metonymy.com.1082 > sloth.metonymy.com.domain: 6699+ PTR? 3com-net.bga.com. (34)
21:14:10.592538 sloth.metonymy.com.domain > dahan.metonymy.com.1082: 6699 NXDomain* 0/1/0 (103)
21:14:10.593631 dahan.metonymy.com.1083 > sloth.metonymy.com.domain: 6700+ PTR? 3com-net. (26)
21:14:10.619418 sloth.metonymy.com.domain > dahan.metonymy.com.1083: 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 3com-net.bga.com, 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)
Name: Dave Huang | Mammal, mammal / their names are called /
INet: email@example.com | 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++