Subject: | |
From: | |
Reply To: | |
Date: | Tue, 28 Jul 1998 14:08:55 GMT |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hello Dave,
You can use nslookup to solve your problem. If you don't have an access
to nslookup, then you can try the following C program that I wrote
specially to address your problem.
You can enter the posix shell and save the following program in a file
say 'hstbyadr.c'.
Then from the posix shell itself you can compile as below:
c89 -D_POSIX_SOURCE -D_SOCKET_SOURCE hstbyadr.c -lsocket -o HSTBYADR
Next execute the HSTBYADR program either from the POSIX shell or from CI.
Here follows my program source.
-------------------------------------------------------------------------------
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
main(argc, argv)
int argc;
char * argv[];
{
/* char hstName[128]; */
char dotNotation_hstAddr[128];
struct hostent * hePtr;
struct in_addr inet_hstAddr;
while(1)
{
int i;
printf("\n\n\nEnter the host ADDRESS in dot notation: ");
gets(dotNotation_hstAddr);
if( strcmp(dotNotation_hstAddr, "") == 0 )
break;
inet_hstAddr.s_addr = inet_addr(dotNotation_hstAddr);
hePtr = gethostbyaddr (
(char *) &inet_hstAddr,
sizeof (struct in_addr),
AF_INET);
printf("The host details are as follows:\n");
printf(" The official name of the host is : %s\n",
hePtr->h_name);
i = 0;
printf(" The alternate names for the host are:\n");
while(hePtr->h_aliases[i])
{
printf("\t-%s\n", hePtr->h_aliases[i]);
i++;
}
}
}
-------------------------------------------------------------------------------
Hope this helps.
--
Shivanand ([log in to unmask])
--
> All,
>
> Has anyone got any ideas as to how i can get a nodename from a given IP
address.
> I need to track down a user and only have the IP address. If i can get the
> nodename from this i can trace their logon hence the question
>
> Thanks
>
> Dave Ross
>
|
|
|