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);
}
}
[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!
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