Command Line DNS Reverse Lookup

Command Line DNS Reverse Lookup

Post by Dave Steel » Wed, 07 Dec 1994 04:45:16



I need a command line utility for converting IP addresses to
host names. This utility needs to work from a script, so nslookup is
not a particularly good choice. Is there a simple program that will
do this for me?

I could also use one that converts from port number to service name.

 
 
 

Command Line DNS Reverse Lookup

Post by Logan Sh » Wed, 07 Dec 1994 14:10:17



Quote:>I need a command line utility for converting IP addresses to
>host names. This utility needs to work from a script, so nslookup is
>not a particularly good choice. Is there a simple program that will
>do this for me?

-  Your system might have 'host'.  In which case, you just type
"host 127.0.0.1" and parse the output (unfortunately, output may
vary from Unix to Unix).

-  You can use nslookup, as in

        #! /bin/sh

        namebyip ()
                {
                arpa=`
                        echo "$1" |
                        awk -F. '{ print $4"."$3"."$2"."$1".in-addr.arpa" }'
                     `

                { echo 'set q=any'; echo "$arpa" } |
                        nslookup |
                        grep "$arpa" |
                        sed -e 's/.* //'
                }

        namebyip 128.83.139.9

-  It's also possible to do it in perl, by calling gethostbyname.

Quote:>I could also use one that converts from port number to service name.

Something like this:

        #! /usr/local/bin/perl


                {
                $service = getservbyport ($_, 'tcp');
                print "$_: $service\n";
                }

Note, it's probably also possible to use perl converting from IP address
to IP hostname, using gethostbyaddr().

Hope that helps...

Adios,
  Logan
--
Logan Shaw, Unix System Administrator
"Everything is a struggle in Unix"  -Dave Keenan

 
 
 

Command Line DNS Reverse Lookup

Post by Alan B. Eva » Thu, 08 Dec 1994 04:03:19


: I need a command line utility for converting IP addresses to
: host names. This utility needs to work from a script, so nslookup is
: not a particularly good choice. Is there a simple program that will
: do this for me?

: I could also use one that converts from port number to service name.

Here's one I call ip2name :

------cut here------
#!/bin/sh
#
# Convert numeric internet address to name
#
(
echo set q=PTR
for i
do
SVIFS="$IFS"
IFS="."
set -- $i
IFS="$SVIFS"
echo "$4.$3.$2.$1.in-addr.arpa"
done
) | nslookup
------cut here------
--


ICBM     :   33 39'     North   Cruise  :   33 39' 37"  North
         :  117 59'     West            :  117 59' 54"  West

 
 
 

Command Line DNS Reverse Lookup

Post by Reto Lichtensteig » Thu, 08 Dec 1994 04:28:52



: >I need a command line utility for converting IP addresses to
: >host names. This utility needs to work from a script, so nslookup is
: >not a particularly good choice. Is there a simple program that will
: >do this for me?

: -  Your system might have 'host'.  In which case, you just type
: "host 127.0.0.1" and parse the output (unfortunately, output may
: vary from Unix to Unix).

Ask archie to find dig(1) for you ...

% dig ptolemy-ethernet.arc.nasa.gov
QUESTIONS:
        ptolemy-ethernet.arc.nasa.gov, type = A, class = IN

Querying server (# 1) address = 137.203.5.1
got answer:
ANSWERS:
        ptolemy-ethernet.arc.nasa.gov
        type = A, class = IN, ttl = 1 day, dlen = 4
        internet address = 128.102.114.134
%

(I did abbreviate the output somewhat  <g>)

Reto L.
--

System Administrator    Horizon Research Inc    (617) 466-8304
                        Waltham MA 02154

"The system has been practicing a noncomputational lifestyle ever
since the boot disk became I/O challenged."

 
 
 

Command Line DNS Reverse Lookup

Post by Phi H Truo » Sat, 10 Dec 1994 07:53:18





>>I need a command line utility for converting IP addresses to
>>host names. This utility needs to work from a script, so nslookup is
>>not a particularly good choice. Is there a simple program that will
>>do this for me?

I used dig which is a utility similar to nslookup bundled with bind
4.9.x.  You can get bind at gatekeeper.dec.com:/pub/misc/vixie.

% dig -x <your ip address here>
--
_____
Phi H. Truong              "Hmmmmmmmm....... "      

Systems Analyst            237 Durham Center         ph: (515) 294 -1420

 
 
 

Command Line DNS Reverse Lookup

Post by Jochen Be » Wed, 14 Dec 1994 11:47:39



>: I need a command line utility for converting IP addresses to
>: host names. This utility needs to work from a script, so nslookup is
>: not a particularly good choice. Is there a simple program that will
>: do this for me?

Try installing 'host' from the BIND Package:

penthesilea:/home/TI/bern% host 136.199.14.144
Name: kleopatra.uni-trier.de
Address: 136.199.14.144
Aliases:

Quote:>: I could also use one that converts from port number to service name.

penthesilea:/home/TI/bern% ypmatch 20/tcp services
ftp-data        20/tcp

;-)

penthesilea:/home/TI/bern% grep '[^0-9]20/tcp' /etc/services
ftp-data        20/tcp

Regards,
                                                                        J. Bern
--

/ J. \ <A HREF="http://www.informatik.uni-trier.de/~bern/">My Homepage</A> /  \
\Bern/ FINGER, NEWS ETC. AT THIS SITE ARE BROKEN, PLEASE USE MAIL (+ WWW)! \  /
 \  /  P.O. Box 1203, 54202 Trier, Germany, Europe -- Ham Call Sign: DD0KZ  \/

 
 
 

1. disable reverse DNS look-up - how do I do it

Can anyone help please.

I have an in-house developed application running on Solaris which uses DNS
to look-up IP addresses for outbound calls.

I recently discovered that by default the Solaris O/S does a reverse DNS
look-up in order to identify incoming sessions.  The incoming calls are not
from registered addresses and so in the normal course of events the DNS
simply returns no match.

I recently lost my Internet access, which meant that my internal DNS could
not validate any IP addresses that it did not recognise.  It has a choice of
three DNS servers to request answers from, consequently it timed out three
times prior to returning a failed message to the Solaris server.  This had
the effect of making the incoming session wait about 2 minutes prior to
connecting (and caused the internal DNS to become processor bound).

My application does not need to identify an domain name for incoming calls -
How do I disable reverse DNS and still leave domain name resolution in
place?

I got around the problem temporarily by disabling DNS and using a local
hosts file, however this is far from ideal.

2. i/f for registration of named transformation fn's

3. how to change reversed DNS lookup timeout setting

4. Possible solution for min()/max() war

5. DNS reverse lookup

6. MkLinux on a Mac 9150 ?

7. Double-Reverse DNS lookup

8. mail test

9. qpopper & reverse DNS lookup

10. reverse dns lookup to my own address

11. Could not get reverse DNS lookup outside our company

12. Reverse DNS lookups by FTPd

13. Apache error_log and reverse DNS lookups