Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!stan!imp From: imp@solbourne.com (Warner Losh) Newsgroups: comp.protocols.tcp-ip Subject: Re: Confirming DNS name matches local host name Message-ID: <1991May30.214701.9756@solbourne.com> Date: 30 May 91 21:47:01 GMT References: <891@bcstec.boeing.com> Distribution: na Organization: Solbourne, User Interface Group Lines: 44 In article <891@bcstec.boeing.com> ced@bcstec.uucp (Charles Derykus) writes: >Given an internet IP, is there a way to retrieve what the host at that IP >actually calls itself. In other words, I want to confirm that what DNS >says actually matches the local host name. gethostbyaddr(3) should do the trick (don't know if it will or not if you are running NIS): # include # include # include int main (argc, argv) int argc; char **argv; { struct hostent *h; u_long ip /* assume ip gets set somehow */ h = gethostbyname (&ip, sizeof (u_long), AF_INET); if (h == NULL) { fprintf (stderr, "Can't get host info for this host\n"); exit (1); } printf ("official name: %s\n", h -> h_name); } alternatively, there is nslookup: Given IP address 1.2.3.4 nslookup > set q=ptr > 4.3.2.1.in-addr.arpa. should also do the trick. Warner -- Warner Losh imp@Solbourne.COM Free to a good home: 10,000 Miller Moths. Must promise not to breed them.