nslookup may not be a good test for gethostbyname() resolution. Ping might
be better. Check out this article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q200525, especially:
"Nslookup will always devolve the name from the current context. If you fail
to fully qualify a name query (that is, use trailing dot), the query will be
appended to the current context. For example, the current DNS settings are
att.com and a query is performed on www.microsoft.com; the first query will
go out as www.microsoft.com.att.com because of the query being unqualified.
This behavior may be inconsistent with other vendor's versions of Nslookup,
and this article is presented to clarify the behavior of Microsoft Windows
NT Nslookup.exe"
Still, while it means your nslookup query is really being performed on
netman.company.pvt, that should resolve...
Oh ... wait ... 2.0 demo ... um, wrong version ... -g in 2.0 was netflow ...
Same basic construct:
static void initNetFlowExporter(char* dstHost, int dstPort) {
struct hostent *hostAddr = gethostbyname(dstHost);
if(hostAddr == NULL) {
traceEvent(TRACE_INFO, "Unable to resolve address '%s'\n", dstHost);
exit(-1);
}
It has to be some sort of network error... from the gethostbyname man page:
Error return status from gethostbyname and gethostbyaddr is indicated
by
return of a null (0) pointer. The global integer h_errno can then be
checked to see whether this is a temporary failure or an invalid or
unknown host. The routine herror can be used to print an error message
to file descriptor 2 (standard error) describing the failure. If its
argument string is non-NULL, it is printed, followed by a colon and a
space. The error message is printed with a trailing newline. To
simplify variant formatting of messages, hstrerror takes an error
number
(typically h_errno) and returns the corresponding message string.
h_errno can have the following values:
HOST_NOT_FOUND No such host is known.
TRY_AGAIN This is usually a temporary error and means that the
local server did not receive a response from an
authoritative server. A retry at some later time may
succeed.
NO_RECOVERY Some unexpected server failure was encountered. This
is
a non-recoverable error.
NO_DATA The requested name is valid but does not have an IP
address; this is not a temporary error. This means that
the name is known to the name server but there is no
address associated with this name. Another type of
request to the name server using this domain name results
in an answer; for example, a mail-forwarder can be
registered for this domain.
Unfortunately, we're not working on 2.0 any more, but rather 2.0.99RC2+
trying to get 2.1 out the door. I suggest you check back in a couple of
weeks and try the 2.1 demo. I will try & tuck code in to print the h_errno
value...
-----Burton
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
Of Jonathan S. Polacheck
Sent: Friday, June 21, 2002 12:56 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [Ntop-dev] ntop -g on a Win2K system (ntop-2.0-demo.exe)
C:\Program Files\ntop-Win32>nslookup 204.6.15.8
Server: aus-dc02.company.pvt
Address: 204.6.15.251
Name: netman
Address: 204.6.15.8
C:\Program Files\ntop-Win32>nslookup netman
Server: aus-dc02.company.pvt
Address: 204.6.15.251
Name: netman.company.pvt
Address: 204.6.15.8
C:\Program Files\ntop-Win32>ntop -g netman:4444
21/Jun/2002 12:53:56 Unable to resolve address 'netman'
C:\Program Files\ntop-Win32>ntop -g 204.6.15.8:4444
21/Jun/2002 12:54:06 Unable to resolve address '204.6.15.8'
----- Forwarded by Jonathan S. Polacheck/AUSTIN/THE_FUND on 06/21/2002
12:55 PM -----
"Burton M.
Strauss III" To: <[EMAIL PROTECTED]>
<Burton@ntopsu cc: <[EMAIL PROTECTED]>
pport.com> Subject: RE: [Ntop-dev] ntop -g
on a Win2K system (ntop-2.0-demo.exe)
06/21/2002
11:55 AM
All ntop does is use the standard gethostbyname() function. There are some
knowledge base articles about it - fixes in SP2.
Now, it should just return the same thing (see note below from
gethostbyname() man page), but perhaps they are being clever??
Anyway, try
1) nslookup on the numeric address
2) use the name in the -g parameter (or both)
and let us know...
-----Burton
sql.c
static void openSQLsocket(char* dstHost, int dstPort) {
struct hostent *hostAddr = gethostbyname(dstHost);
if(hostAddr == NULL) {
traceEvent(TRACE_INFO, "Unable to resolve address '%s'\n", dstHost);
exit(-1);
}
memcpy(&dest.sin_addr.s_addr, hostAddr->h_addr_list[0],
hostAddr->h_length);
dest.sin_family = AF_INET;
dest.sin_port = (int)htons((unsigned short int)dstPort);
sqlSocket = socket (AF_INET, SOCK_DGRAM, 0);
if(sqlSocket <= 0) {
traceEvent(TRACE_INFO, "Unable to open SQLsocket\n");
exit(-1);
} else {
traceEvent(TRACE_INFO, "Open channel with ntop SQL client running @
%s:%d\n", dstHost, dstPort);
}
}
man gethostbyname
...
The name argument to gethostbyname is a character string
containing an
Internet hostname or an Internet address in standard dot notation (see
inet(3N)). If the name contains no dot, and if the
environment
variable
HOSTALIASES contains the name of an alias file, the alias file is
first
searched for an alias matching the input name. See hostname(5)
for the
alias file format. The addr argument to
gethostbyaddr points to a
buffer
containing a 32-bit Internet host address in network byte
order.
addrlen
contains the address length in bytes; it should be set to
sizeof(struct
in_addr). type specifies the address family and should be
set to
AF_INET.
...
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
Of Jonathan S. Polacheck
Sent: Friday, June 21, 2002 11:12 AM
To: [EMAIL PROTECTED]
Subject: [Ntop-dev] ntop -g on a Win2K system (ntop-2.0-demo.exe)
C:\Program Files\ntop-Win32>nslookup netman
Server: aus-dc02.company.pvt
Address: 204.6.15.251
Name: netman.company.pvt
Address: 204.6.15.8
C:\Program Files\ntop-Win32>ntop -g 204.6.15.8:4444
21/Jun/2002 10:59:10 Unable to resolve address '204.6.15.8'
????
_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://lists.ntop.org/mailman/listinfo/ntop-dev
_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://lists.ntop.org/mailman/listinfo/ntop-dev
_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://lists.ntop.org/mailman/listinfo/ntop-dev