home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / programm / 5676 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  2.1 KB

  1. Xref: sparky comp.unix.programmer:5676 comp.sources.wanted:5359
  2. Newsgroups: comp.unix.programmer,comp.sources.wanted
  3. Path: sparky!uunet!psinntp!hyphenw!dwight
  4. From: dwight@hyphen.com (Dwight Ernest)
  5. Subject: Re: Get hostname from IP address
  6. Message-ID: <1992Dec13.180845.28960@hyphen.com>
  7. Organization: Hyphen, Inc., Wilmington, MA 01887 USA / +1 508 988-0880
  8. References: <Bz2FFM.D4z@avalon.nwc.navy.mil> <1992Dec11.152438.18365@fwi.uva.nl> <1992Dec13.122835.28103@hyphen.com>
  9. Date: Sun, 13 Dec 1992 18:08:45 GMT
  10. Lines: 43
  11.  
  12. dwight@hyphen.com (Dwight Ernest) writes:
  13. >bosman@fwi.uva.nl (Cor Bosman) writes:
  14. >>dejesus@archimedes.nwc.navy.mil (Francisco X DeJesus) writes:
  15.  
  16. >>>I'd like to find a utility I can call from the command-line with an
  17. >>>internet IP address as an argument, and have it return to me the full
  18. >>>hostname related to it. I've looked into the function gethostbyaddr()
  19. >>>but haven't been able to work. I also remember reading about a name-
  20. >>>resolver funtion nres_gethostbyaddr() (sp?), but can't find any
  21. >>>references to it on my system. I'm running SunOS 4.1.2 on a Sparc.
  22.  
  23. >>Hmm..a command-line program huh...why cant you use:
  24.  
  25. >>     nslookup - query domain name servers interactively
  26.  
  27. >Because it's not general enough.  It assumes that BIND is available.
  28. >The best thing would be a wrapper around the gethostbyaddr() call.
  29.  
  30. >Like this, perhaps:
  31.  
  32. >/*
  33. > *    gethostbyaddr
  34. > *
  35. > *    For shell scripts and the like.
  36. > *
  37. > *    Given a network IP address, returns the hostname, if it can.
  38. > *
  39. > */
  40.  
  41. (program omitted)
  42.  
  43. I neglected to mention why  it's not general enough.
  44.  
  45. Gethostbyaddr() uses the library routine from libc.  That library
  46. routine uses whatever underlying mechanism for name-to-address
  47. mapping (or vice-versa) that has been provided.  That might be
  48. file-table lookup, NIC (YP), DNS/BIND, or some combination or
  49. hierarchy of these.  nslookup(8C) uses ONLY DNS/BIND and ignores
  50. any hierarchy that may have been provided.
  51. -- 
  52. --Dwight A. Ernest   R&D Manager (USA)     I speak only for myself.
  53.   Hyphen, Inc./181 Ballardvale St./Wilmington, MA 01887/+1 508 988 0880 x125
  54.   dwight@hyphen.com
  55.