Major problem with hostname resolution in Win2K

Discussion in 'Java' started by chrisrocker90@gmail.com, Oct 5, 2007.

  1. Guest

    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
    , Oct 5, 2007
    #1
    1. Advertising

  2. wrote:
    ...
    >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
    Andrew Thompson, Oct 5, 2007
    #2
    1. Advertising

  3. Lew Guest

    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.


    Andrew Thompson 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.
    > ** <http://www.physci.org/codes/sscce.html>


    Hmm, could this be a clue?

    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?

    --
    Lew
    Lew, Oct 5, 2007
    #3
  4. Guest

    On Oct 5, 3:24 am, "Andrew Thompson" <u32984@uwe> wrote:
    > wrote:
    >
    > ..
    >
    > >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.


    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.
    >
    > ** <http://www.physci.org/codes/sscce.html>
    >
    > --
    > Andrew Thompsonhttp://www.athompson.info/andrew/
    >
    > Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1
    , Oct 5, 2007
    #4
  5. On Fri, 05 Oct 2007 06:32:32 -0000, 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.


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

    /gordon

    --
    Gordon Beaton, Oct 5, 2007
    #5
  6. Guest

    On Oct 5, 9:31 am, Lew <> wrote:
    > 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.

    > Andrew Thompson 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.
    > > ** <http://www.physci.org/codes/sscce.html>

    >
    > Hmm, could this be a clue?
    >
    >
    >
    > 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?
    >
    > --
    > 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.
    , Oct 6, 2007
    #6
  7. Lew Guest

    wrote:
    >> 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?
    >>
    >> --
    >> 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.

    --
    Lew
    Lew, Oct 6, 2007
    #7
  8. wrote:
    ..(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

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

    Message posted via http://www.javakb.com
    Andrew Thompson, Oct 6, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kokwooi

    Major Major Problem With ASP.NET

    kokwooi, Sep 18, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    664
    NuTcAsE
    Sep 19, 2003
  2. Andrew FPGA
    Replies:
    0
    Views:
    969
    Andrew FPGA
    Sep 26, 2005
  3. AWieminer
    Replies:
    0
    Views:
    748
    AWieminer
    Jul 12, 2005
  4. Jef Driesen
    Replies:
    2
    Views:
    1,685
    Jef Driesen
    Jan 12, 2006
  5. ara howard
    Replies:
    0
    Views:
    222
    ara howard
    Oct 28, 2003
Loading...

Share This Page