Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reverse DNS lookup in Java

2 views
Skip to first unread message

kx dave

unread,
Mar 22, 2003, 12:22:16 PM3/22/03
to
Hello,

I'm trying to get reverse DNS via Java to work on my SuSE Linux 8.1 box
using JDK 1.4. Every time it returns the IP address instead of the hostname.
The code works on other platforms I've tested it on: Red Hat Linux 8,
Windows 2000, and Solaris 8 for Intel...all using JDK 1.4. But for some
reason it doesn't on SuSE 8.1 and I can't figure out why. To my knowledge
I'm not implementing any Java security policies that would prevent a reverse
DNS lookup from happening. Nslookup on the box returnst the correct
hostname.

I've been searching the newsgroup for a few weeks now and cannot find the
solution. I'd appreciate any help or a pointer in the right direction.

Thanks in advance,
-dave

Here is the code:

IP.java
~~~~~~

import java.net.InetAddress;

public class IP
{
public static void main(String[] args)
{

String sRemoteIP = "111.111.111.111"; // substituted for real IP
addy
String sRemoteHost = "";
InetAddress remoteIP = null;

try {
//get IP address
remoteIP = InetAddress.getByName(sRemoteIP);
// get hostname
sRemoteHost = remoteIP.getHostName();
}
catch(Exception e)
{
System.out.println("exception " + e.toString());
}
// print out hostname (prints IP address on SuSE 8.1)
System.out.println("remote host is " + sRemoteHost);

}
}


Lothar Kimmeringer

unread,
Mar 22, 2003, 3:07:11 PM3/22/03
to
"kx dave" <kx_...@yahoo.com> schrieb:

[reverse DNS not working on SuSE 8.1]

>Here is the code:
>
>IP.java

[...]

Is there an exception being thrown or is just the IP-address
being returned as answer? Is the nslookup giving back the
name or is it returning the IP as well?


Regards, Lothar
--
Lothar Kimmeringer E-Mail: spam...@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!

kx dave

unread,
Mar 22, 2003, 3:51:09 PM3/22/03
to
>
> Is there an exception being thrown or is just the IP-address
> being returned as answer?

Just the IP address is being returned as the answer. No exceptions are being
thrown.

> Is the nslookup giving back the
> name or is it returning the IP as well?

Nslookup returns the correct name. I'm stumped...

Thanks,
Dave


0 new messages