Convert From IP Address To Hostname

Convert From IP Address To Hostname

Post by Paul Roebu » Sun, 09 Mar 1997 04:00:00



Does anyone have some C source that can convert a dot-formatted IP address
into the original hostname?  Essentially, this should provide the same
functionality
as `nslookup` invoked in a similar manner.

TIA

--
Out of the 10Base-T, through the router, down the T1, over the
leased line, off the bridge, past the firewall... nothing but Net.

 
 
 

Convert From IP Address To Hostname

Post by Jeff Ha » Mon, 10 Mar 1997 04:00:00




>Does anyone have some C source that can convert a dot-formatted IP address
>into the original hostname?  Essentially, this should provide the same
>functionality
>as `nslookup` invoked in a similar manner.

>TIA

     check out gethostbyaddr to see if it will help

jeff

--

With a PC, I always felt limited by the software available.
                      On Unix, I am limited only by my knowledge.

 
 
 

Convert From IP Address To Hostname

Post by Andrew Giert » Mon, 10 Mar 1997 04:00:00


 Paul> Does anyone have some C source that can convert a dot-formatted
 Paul> IP address into the original hostname?  Essentially, this
 Paul> should provide the same functionality as `nslookup` invoked in
 Paul> a similar manner.

The basic idea is to use inet_aton() to parse the numeric address,
then gethostbyaddr() to look up the host name.

There is one thing you should be cautious of, though: the person
controlling the reverse DNS for any given address can supply any hostname
he wants for that address, even hostnames that don't belong to him. If
you are using reverse-lookups in any security-relevent situation (which
includes any case where hostnames are being logged rather than raw IP
numbers), then you should verify that the claimed name does actually
belong to the specified IP number, by looking up the name with
gethostbyname() and checking that the original IP address appears
somewhere in the list of addresses for that hostname.

--
Andrew.

 
 
 

1. command to convert hostname to IP address

# I need a command that I can use in a script to convert a hostname in
# /etc/hosts to its appropriate IP address. Anyone?
#

Try arp <hostname>

Matthew

--
"Press that panel and pray very, very fast." Lennier, Babylon 5

| Matthew T. Jachimstal  N9LMW  CS Major  Michigan Technological University

| Voice: 906-487-3997    <*>    [\]      WWW: http://jachsys.resnet.mtu.edu
| PGP ID: 683F741D     FP: 8B 6A 03 A3 E2 5C 71 64  93 D0 22 17 0E 2B C6 AF

2. Berkeley license?

3. Convert ip-addresses in file with hostname

4. Set Xterm icon name to "`hostname`:`basename $cwd`"?

5. How can I convert a tty address to an IP address in older SCO UNIX

6. Configuring an ESS 1688 Soundcard?

7. using mac address instead of an IP address of hostname

8. Cd-burning ulility...

9. how to convert mac address to ip address

10. Convert ethernet address to ip address

11. Convert IP Name Address to Numeric Address

12. Converting IP numbers to hostnames in log file

13. ping works for IP Addresses but fails for hostname