Major problem with hostname resolution in Win2K

C

chrisrocker90

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
 
A

Andrew Thompson

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>

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1
 
M

mark.donaghue

(e-mail address removed) wrote:

..


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.

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());
}
}
}

}
 
G

Gordon Beaton

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

--
 
C

chrisrocker90

Hmm, could this be a clue?





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

Coincidence?

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.
 
L

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.

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.
 
A

Andrew Thompson

... 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top