DNS reverse lookup

Kevin Darcy kcd at daimlerchrysler.com
Tue May 16 22:24:32 UTC 2000


Martin wrote:

> Hi,
> I am writing a program to examine a web servers log file. If the
> web server has the option for resolving the IP address off, as
> with Apache 1.3 default. Then I am faced with the problem of
> resolving the IP address into a host name, thus I want to do a
> reverse DNS lookup. I am writing this program in Java. So
> 1/ Is it possible to do a reverse DNS in Java code.
> 2/ I have tried the following code, and it does not work -
>
> InetAddress r;
>        String s;
>
>        try {                // use the address you are concerned
> with
>            r = InetAddress.getByName("192.122.98.61");

You'd need the Java equivalent of the gethostbyaddr() C library call.
You'd also need to have the ability to resolve Internet names, which may
be non-trivial if you currently run an isolated internal-root
architecture behind proxy firewalls. I had to set up a special
forwarding arrangement for our internal web log-analyzing,
statistics-gathering machine to be able to do something similar. For
traffic/performance reasons, you may want to use a *caching* server as
an intermediary between the statistics machine and the Internet, since
you'll probably find that the addresses in the web logs "cluster" a lot
and it would be very wasteful to send the same queries to the Internet
over and over. Lastly, you should also be aware that many addresses on
the Internet don't have reverse records, even if they have forward
records pointing to them. So the whole exercise is of limited value even
if you can get it to work.


- Kevin




More information about the bind-users mailing list