From owner-freebsd-java@FreeBSD.ORG Mon Aug 23 15:51:58 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A4DE116A4CE for ; Mon, 23 Aug 2004 15:51:58 +0000 (GMT) Received: from mgr2.xmission.com (mgr2.xmission.com [198.60.22.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8100A43D6B for ; Mon, 23 Aug 2004 15:51:58 +0000 (GMT) (envelope-from glewis@eyesbeyond.com) Received: from [198.60.22.130] (helo=mgr10.xmission.com) by mgr2.xmission.com with esmtp (Exim 3.35 #1) id 1BzH6z-0004CX-02; Mon, 23 Aug 2004 09:51:57 -0600 Received: from [166.70.56.15] (helo=misty.eyesbeyond.com) by mgr10.xmission.com with esmtp (Exim 4.32) id 1BzH6z-00047Z-Po; Mon, 23 Aug 2004 09:51:57 -0600 Received: from misty.eyesbeyond.com (localhost.eyesbeyond.com [127.0.0.1]) i7NFptgs015856; Mon, 23 Aug 2004 09:51:56 -0600 (MDT) (envelope-from glewis@eyesbeyond.com) Received: (from glewis@localhost) by misty.eyesbeyond.com (8.12.11/8.12.11/Submit) id i7NFptMl015855; Mon, 23 Aug 2004 09:51:55 -0600 (MDT) (envelope-from glewis@eyesbeyond.com) X-Authentication-Warning: misty.eyesbeyond.com: glewis set sender to glewis@eyesbeyond.com using -f Date: Mon, 23 Aug 2004 09:51:54 -0600 From: Greg Lewis To: Brad Karp Message-ID: <20040823155154.GA15838@misty.eyesbeyond.com> References: <20040820030209.9E7D643D1D@mx1.FreeBSD.org> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20040820030209.9E7D643D1D@mx1.FreeBSD.org> User-Agent: Mutt/1.4.2.1i Content-Type: multipart/mixed; boundary="r5Pyd7+fXNt84Ff3" X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on mgr10.xmission.com X-Spam-Level: X-Spam-Status: No, hits=-4.9 required=8.0 tests=BAYES_00, T_TM2_M_HEADER_IN_MSG autolearn=no version=2.63 X-SA-Exim-Connect-IP: 166.70.56.15 X-SA-Exim-Mail-From: glewis@eyesbeyond.com X-SA-Exim-Version: 4.0 (built Sat, 24 Apr 2004 12:31:30 +0200) X-SA-Exim-Scanned: Yes (on mgr10.xmission.com) cc: freebsd-java@freebsd.org Subject: Re: getHostName() broken? X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2004 15:51:58 -0000 --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 system, > 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 Are you sure resolution works for you normally? Can you run host(1) and check that lookups succeed for the hosts? -- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="HostName.java" import java.net.*; class HostName { public static void main(String[] args) { try { InetAddress addr = InetAddress.getByName("66.35.250.151"); System.out.println(addr.getHostAddress()); System.out.println(addr.getHostName()); } catch (Throwable t) { t.printStackTrace(); } } } --r5Pyd7+fXNt84Ff3--