java f00lz

Discussion in 'OT Technology' started by johnnywallywallace, Dec 12, 2003.

  1. so I want to grab the IP address of the host a small app is running on. only problem is, I don't see how one specifies WHICH ethernet interface, if you're running multiple interfaces ... I see where I can grab my hostname then get all IPs by hostname, I suppose I could then ignore all 192. and 10. addresses to determine my external IP, but I'd have to think there'd be a smarter solution ...
  2. SLED

    SLED custom title

    Sep 20, 2001
    Likes Received:
  3. ph1

    ph1 Guest

    use to get an enumeration of all interfaces on the host, then for each interface in the enum get the InetAddresses using

    how to determine what you think is a valid address is up to you.
  4. so it sounds like, like I said, I have to grab all and rule out those I know to be internal ... there's no better way than full enumeration? there's no way to specify getNetworkInterface("eth0") or something handy and direct like that?
  5. CompiledMonkey

    CompiledMonkey New Member

    Oct 26, 2001
    Likes Received:
    Richmond, VA
    Check the APIs. There certainly could be something like that.
  6. aphoric

    aphoric Even if god did exist, it would be necessary to ab

    Aug 29, 2003
    Likes Received:
    Leaving Afghanistan
    What he said...


    public static Enumeration getNetworkInterfaces()
    throws SocketException
    Returns all the interfaces on this machine. Returns null if no network interfaces could be found on this machine. NOTE: can use getNetworkInterfaces()+getInetAddresses() to obtain all IP addresses for this node

    an Enumeration of NetworkInterfaces found on this machine
    SocketException - if an I/O error occurs.

    And about detirmining the real address, you could start by eliminating all the ones that are in the subnet...

    But, if they are using a router, the real IP is not going to be on their machine at all..
  7. hehe thanks for repeating what I said intially :p I have to get all, as I already knew, and rule out my internals, as I planned. :fawk:

    but thanks for the input.

Share This Page