Hostname from Internet address?

John A. Palkovic palkovic at zippy.fnal.gov
Thu Dec 27 15:19:10 AEST 1990


In article <1990Dec25.070328.4413 at msuinfo.cl.msu.edu> 
	raja at bombay.cps.msu.edu (Narayan S. Raja) writes:

   Given a hostname (e.g. zip.foo.bar.edu), one
   can use a network information program like
   nslookup to find its Internet address.  How
   about the other way round?  Given an internet
   address (e.g. 1.2.3.4), how would one find the 
   complete hostname?

I use the following shell script. You may have to tweak the args to
sed or the sleep command.

#!/bin/sh
#
# Map an IP address to a host name
#
OIFS=$IFS
IFS=.
set -- $1
IFS=$OIFS
PTR=`echo $4.$3.$2.$1.in-addr.arpa`
(
  echo set q=ptr
  sleep 1
  echo $PTR
) | nslookup | sed -e 1,3d -e 's/^.*> //'


--
John Palkovic (708) 840-3527	| palkovic at linac.fnal.gov
"A Superconductor generates electricity without resistance when cooled." 
- Chicago Tribune, Oct. 21, 1990, A-18 



More information about the Comp.unix.questions mailing list