I recently noticed (using ethereal) that I was getting unexpected
DNS queries when I started ssh. I wrote this following program
to try to isolate the problem.
It doesnt work correctly, I cant see why, please advise.
addresses for pages.ebay.com
alias: www.ebay.com
addr: ? x
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
extern int h_errno;
struct hostent *hent;
int main(int argc, char **argv)
{
char **addr;
char *p;
int err;
if (argc>1) {
hent = gethostbyname(argv[1]);
// hent = getipnodebyname(argv[1], AF_INET, 0, &err);
}
printf("addresses for %s\n", hent->h_name);
for (addr = hent->h_aliases; *addr; addr++) {
printf("alias: %s\n", *addr);
}
for (addr = hent->h_addr_list; *addr; addr++) {
printf("addr: %s\n", *addr);
/*
for (p = *addr; *p; p++) {
printf("%c,", *p);
}
printf("\n");
*/
}
// printf("addr: %s\n", hent->h_addr);
Quote:}