Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!att!linac!linac!palkovic From: palkovic@zippy.fnal.gov (John A. Palkovic) Newsgroups: comp.unix.questions Subject: Re: Hostname from Internet address? Message-ID: Date: 27 Dec 90 04:19:10 GMT References: <1990Dec25.070328.4413@msuinfo.cl.msu.edu> Reply-To: palkovic@linac.fnal.gov Organization: Bob's School of Quantum Mechanics Lines: 33 In-Reply-To: raja@bombay.cps.msu.edu's message of 25 Dec 90 07:03:28 GMT In article <1990Dec25.070328.4413@msuinfo.cl.msu.edu> raja@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@linac.fnal.gov "A Superconductor generates electricity without resistance when cooled." - Chicago Tribune, Oct. 21, 1990, A-18