Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Major problem with hostname resolution in Win2K

Thread view: 
chrisrocker90@gmail.com - 05 Oct 2007 07:32 GMT
Hi,

I'm having a terrifically difficult time getting the hostname of my
computer to resolve to the correct, external IP address (as opposed to
127.0.0.1).  I think it's a  Win2K problem, but I'm not sure. I'm
posting here in case someone knows about it, and in case I'm mistaken
and it is just a java problem.

Here's the issue: I'm using java to display the network interfaces and
their names on two identical (more or less) Win2K systems. The
(undesired) result I'm getting on one Win2K system is as follow:

Interface: MS TCP Loopback Interface
Canonical Name: Chris <---- computer name
hostAddress: 127.0.0.1
Interface Broadcomm NeXtrem Gigabit Ehternet Driver
Canonical Name: 192.168.12.20
hostAddress: 192.168.12.20

On another system called "Rock", I get the desired result, with the
exact same code:

Interface: MS TCP Loopback Interface
Canonical Name: 127.0.0.1
hostAddress: 127.0.0.1
Interface Broadcomm NeXtrem Gigabit Ehternet Driver
Canonical Name: ROCK <---- computer name
hostAddress: 192.168.12.20

The apis I'm using are:

NetworkInterface.getNetworkInterfaces

NetworkInterface.getInetAddresses

InetAddresses.getCanonical name.

Anyone know what could cause this behavior? I've tried just about
everything. I think I'm going to have recode around this nasty bug.
That means I'll have to modify some complicated, inherited spaghetti
code, instead of a hoped for tweak.

Any help would be vastly appreciated!

Chris
Andrew Thompson - 05 Oct 2007 08:24 GMT
...
>I'm having a terrifically difficult time ...
>...  I think it's a  Win2K problem, but I'm not sure.

Testing beats suspicion 9 times out of ten*.
So keeping that in mind arrange these..

>NetworkInterface.getNetworkInterfaces
>NetworkInterface.getInetAddresses
>InetAddresses.getCanonical name.

..into an SSCCE** and I will provide some test
results for this Win XP Pro box.

* ..and 83.7% of statistics are invented on the spot.

** <http://www.physci.org/codes/sscce.html>

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Lew - 05 Oct 2007 14:31 GMT
chrisrocker90@gmail.com wrote:
>> I'm having a terrifically difficult time getting the hostname of my
>> computer to resolve to the correct, external IP address (as opposed to
>> 127.0.0.1).  I think it's a  Win2K problem, but I'm not sure. I'm
>> posting here in case someone knows about it, and in case I'm mistaken
>> and it is just a java problem.

> Testing beats suspicion 9 times out of ten*.
> So keeping that in mind arrange these..
> ..into an SSCCE** and I will provide some test
> results for this Win XP Pro box.
> ** <http://www.physci.org/codes/sscce.html>

Hmm, could this be a clue?

chrisrocker90@gmail.com wrote:
>> Canonical Name: Chris <---- computer name
>> hostAddress: 127.0.0.1
,,,
>> Canonical Name: ROCK <---- computer name
>> hostAddress: 192.168.12.20

And you say "Chris" resolves to 127.0.0.1, and "ROCK" resolves to 192.168.12.20?

Coincidence?

Signature

Lew

chrisrocker90@gmail.com - 06 Oct 2007 13:21 GMT
> chrisrocke...@gmail.com wrote:
> >> I'm having a terrifically difficult time getting the hostname of my
[quoted text clipped - 23 lines]
> --
> Lew

No, not a coincidence - it's a result of how the OS is resolving the
computer name differently on separate   hosts.  On both machines, I
want the address to resolve to external ip addresss. On "Chris", it's
not doing that correctly, on "ROCK", it is.
Lew - 06 Oct 2007 14:55 GMT
>> chrisrocke...@gmail.com wrote:
>>>> Canonical Name: Chris <---- computer name
[quoted text clipped - 13 lines]
> want the address to resolve to external ip addresss. On "Chris", it's
> not doing that correctly, on "ROCK", it is.

Um, well, you see, err, my comment was based on my misunderstanding of what
you wrote, which is why I canceled it.  Sorry about that.

Signature

Lew

mark.donaghue@gmail.com - 05 Oct 2007 14:59 GMT
> chrisrocke...@gmail.com wrote:
>
[quoted text clipped - 12 lines]
> .into an SSCCE** and I will provide some test
> results for this Win XP Pro box.

Of course, you are right. Here is the code:

import java.net.*;
import java.util.*;

public class GetPublicHostName {

    public static void main (String args[]) throws Throwable{
        System.out.println("abc");
        NetworkInterface iface = null;
        for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
        ifaces.hasMoreElements();){
            System.out.println("efg");
            iface = (NetworkInterface)ifaces.nextElement();
            System.out.println("xInterface:" + iface.getDisplayName());
            InetAddress ia = null;
            for (Enumeration ips = iface.getInetAddresses();
ips.hasMoreElements();){
                ia = (InetAddress)ips.nextElement();
                System.out.println(ia.getCanonicalHostName() + " " +
ia.getHostAddress());
            }
        }
    }

}

> * ..and 83.7% of statistics are invented on the spot.
>
[quoted text clipped - 4 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1
Andrew Thompson - 06 Oct 2007 15:19 GMT
..(provide)
>> ...SSCCE** and I will provide some test
>> results for this Win XP Pro box.
>
>... Here is the code:
...
>public class GetPublicHostName {

abc
efg
xInterface:MS TCP Loopback interface
localhost 127.0.0.1
efg
xInterface:SiS 900-Based PCI Fast Ethernet Adapter
210.49.14.119 210.49.14.119

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Gordon Beaton - 05 Oct 2007 15:19 GMT
> I'm having a terrifically difficult time getting the hostname of my
> computer to resolve to the correct, external IP address (as opposed
> to 127.0.0.1). I think it's a Win2K problem, but I'm not sure. I'm
> posting here in case someone knows about it, and in case I'm
> mistaken and it is just a java problem.

I'm inclined to think this is a host configuration problem.

/gordon

--


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.