Re: Tool to find out info about machine ?
There are functions in the C lib that get host information by name or IP
number. I have it wrapped up with a lot of other `play' stuff, but here
are the most significant lines of code.
sock = socket(AF_INET, SOCK_STREAM, 0 );
if( !sock )
goto abort;
if( inet_aton(argv[1], &addr) )
{
printf( "Getting host by address\n" );
host = gethostbyaddr( (char *)&addr, sizeof(addr), AF_INET );
}
else
{
printf( "getting host by name\n" );
host = gethostbyname(argv[1]);
}
if( host )
print_host_info( host );
else
printf("Look up failure\n");
--
Sincerely,
David Smead
http://www.amplepower.com.
On Mon, 29 Apr 2002, Shawn McMahon wrote:
> begin Kapil Khosla quotation:
> > I am interested in knowing the hostname, possibly location (server),of a remote machine whose IP address is known to me,
>
> For hostname information, try "host". This will only work if they have
> reverse DNS set up for that IP address, and set up "correctly".
>
> For location, you are largely screwed because this information isn't
> stored in any standardly-accessible way, but you might be able to make
> some inferences using "traceroute". Those inferences can easily be
> wrong, however.
>
> The surest way to get what you want is to ask the administrator of the
> box, because there's nothing that says he has to set up reverse DNS to
> match his hostname, and he may not be in control of the reverse DNS at
> all.
>
> For information on how to use those commands:
>
> man host
> man traceroute
>
> If you don't have either of those programs, I recommend the following
> packages:
>
> traceroute
> bind9-host
>
> There is also a "host" package, but it has a serious feature ommission
> that the maintainer sees as a "wishlist" item. bind9-host doesn't have
> this particular issue.
>
> Note that there are many other programs that will do similar or
> identical things to these. As usual, there's more than one way to do
> it, and someone will most certainly think my way is wrong. These
> programs are a good start for you.
>
>
>
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: