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