Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Aug 2004 12:03:53 -0400
From:      Brad Karp <bkarp+@cs.cmu.edu>
To:        Greg Lewis <glewis@eyesbeyond.com>
Cc:        freebsd-java@freebsd.org
Subject:   Re: getHostName() broken? 
Message-ID:  <20040823160427.4F91943D2F@mx1.FreeBSD.org>
In-Reply-To: Your message of "Mon, 23 Aug 2004 09:51:54 MDT." <20040823155154.GA15838@misty.eyesbeyond.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20040823155154.GA15838@misty.eyesbeyond.com>you write:
>On Thu, Aug 19, 2004 at 11:01:30PM -0400, Brad Karp wrote:
>> I'm running 4.9-RELEASE, and have built the jdk1.4.2 port using revision 5
>> of the FreeBSD patch kit.
>> 
>> I have a visualization application written in Java by a colleague that I've
>> been running. The application shows nodes in a large-scale distributed syste
>m,
>> and allows clicking on a host to show its Internet hostname.
>> 
>> The code uses getHostName() to do this.
>> 
>> I find that these reverse DNS lookups *all* fail; getHostName() returns a
>> String that is a textual representation of the IP address. (There's no
>> security manager involved here, BTW. The reference for getHostName() says
>> the security manager may check for authorization on getHostName() calls,
>> but I've not changed my Java runtime's security policy from the defaults.)
>> 
>> Further poking reveals that *no* outbound DNS queries (traffic destined for
>> UDP or TCP port 53) are being generated for these reverse name lookups!
>> 
>> I'm perplexed. Can it really be that InetAddress.getHostName() is broken on
>> FreeBSD? Has anyone seen similar behavior, and if so, can you propose a
>> workaround, apart from linking in C code to do these reverse name lookups?
>
>Works for me.  Test code attached.  Here is the output:
>
>> java -cp . HostName
>66.35.250.151
>star.slashdot.org

Many thanks for following up, Greg!

Doesn't work for me, alas! Running your test code, the output is:

> $JAVAHOME/bin/java -cp . HostName
66.35.250.151
66.35.250.151

>Are you sure resolution works for you normally?  Can you run host(1) and
>check that lookups succeed for the hosts?

Yes--this is my desktop host. Name resolution works flawlessly for me at all
times on a daily basis. To wit:

> host 66.35.250.151
151.250.35.66.IN-ADDR.ARPA is a nickname for 151.0/24.250.35.66.IN-ADDR.ARPA
151.0/24.250.35.66.IN-ADDR.ARPA domain name pointer star.slashdot.org

My box:

> uname -a
FreeBSD sewickley.research.intel-research.net 4.9-RELEASE FreeBSD 4.9-RELEASE #2: Sat May 15 03:06:11 EDT 2004     bkarp@sewickley.research.intel-research.net:/usr/src/sys/compile/SEWICKLEY  i386

> $JAVAHOME/bin/java -version
java version "1.4.2-p5"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-p5-bkarp_13_nov_2003_01_32)
Java HotSpot(TM) Client VM (build 1.4.2-p5-bkarp_13_nov_2003_01_32, mixed mode)

I should add that forward lookups appear to work in Java on my box--use them
all the time to make outbound network connections from Java programs.

Again, the odd thing is that I don't see queries going out on the wire for
reverse lookups done in Java with getHostName(). Bizarre.

Other suggestions most welcome--am happy to try other tests, as well.

Thanks again,
-Brad, bkarp@cs.cmu.edu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040823160427.4F91943D2F>