Detecting virtual IP addresses

Discussion in 'Java' started by Gordon Beaton, Dec 5, 2005.

  1. On Mon, 05 Dec 2005 20:19:25 GMT, Joseph Dionne wrote:
    > Is there anyway to detect a virtual IP address?
    >
    > I currently use NetworkInterface to enumerate all local IP
    > addresses. I then filter out the isLocalAddress and all Inet6Address
    > objects, but I do not know how to detect a virtual IP address,
    > provided by VPN connection or VMWare.
    >
    > The application binds the client socket to each NIC (IP address) on
    > the server to light up all interfaces, however Socket.bind() fails
    > on virtual IP addresses, so I need detect and filter them out.


    It's not entirely clear what you mean by "the client binds the socket
    to each NIC on the server". The *client* can't bind sockets to the
    *servers* interfaces, it can bind sockets to its own interfaces. Do
    you mean connect?

    At any rate, it seems you answer your own question: do the filtering
    by noticing which ones fail. Conceptually there is no difference
    between the virtual interfaces created by vmware and any physical
    interface. In particular they should appear equivalent to your
    application (and I don't see why your operation should fail).

    Another alternative is to see which ones are called "vmnet*".

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Dec 5, 2005
    #1
    1. Advertising

  2. Is there anyway to detect a virtual IP address?

    I currently use NetworkInterface to enumerate all local IP addresses. I then
    filter out the isLocalAddress and all Inet6Address objects, but I do not know
    how to detect a virtual IP address, provided by VPN connection or VMWare.

    The application binds the client socket to each NIC (IP address) on the server
    to light up all interfaces, however Socket.bind() fails on virtual IP
    addresses, so I need detect and filter them out.

    Thanks.
    Joseph
     
    Joseph Dionne, Dec 5, 2005
    #2
    1. Advertising

  3. Gordon Beaton wrote:
    > On Mon, 05 Dec 2005 20:19:25 GMT, Joseph Dionne wrote:
    >
    >>Is there anyway to detect a virtual IP address?
    >>
    >>I currently use NetworkInterface to enumerate all local IP
    >>addresses. I then filter out the isLocalAddress and all Inet6Address
    >>objects, but I do not know how to detect a virtual IP address,
    >>provided by VPN connection or VMWare.
    >>
    >>The application binds the client socket to each NIC (IP address) on
    >>the server to light up all interfaces, however Socket.bind() fails
    >>on virtual IP addresses, so I need detect and filter them out.

    >
    >
    > It's not entirely clear what you mean by "the client binds the socket
    > to each NIC on the server". The *client* can't bind sockets to the
    > *servers* interfaces, it can bind sockets to its own interfaces. Do
    > you mean connect?


    Sorry, "my server" is synonymous to "my system," i.e. I bind my client side
    socket using Socket.bind(SocketAddress). This picks the interface on the
    local system to use for the connection when Socket.connect() is called.

    >
    > At any rate, it seems you answer your own question: do the filtering
    > by noticing which ones fail. Conceptually there is no difference
    > between the virtual interfaces created by vmware and any physical
    > interface. In particular they should appear equivalent to your
    > application (and I don't see why your operation should fail).
    >


    Obviously there is a difference between "virtual interfaces" and physical
    interfaces, i.e. NIC cards. Socket.bind() is not throwing an exception, but
    rather Socket.connect() is timing out on connections from the local virtual
    "interfaces," even though it is on the same network as the remote host.

    It is my assumption that I cannot bind to a virtual "interface," and I could
    be wrong. However, since the only "error" is a connection timeout, that does
    not provide any useful information to detect virtual IP addresses.

    > Another alternative is to see which ones are called "vmnet*".
    >
    > /gordon
    >
     
    Joseph Dionne, Dec 5, 2005
    #3
  4. Never mind. My problem is most definitely a routing problem.

    Joseph

    Joseph Dionne wrote:
    > Is there anyway to detect a virtual IP address?
    >
    > I currently use NetworkInterface to enumerate all local IP addresses. I
    > then
    > filter out the isLocalAddress and all Inet6Address objects, but I do not
    > know
    > how to detect a virtual IP address, provided by VPN connection or VMWare.
    >
    > The application binds the client socket to each NIC (IP address) on the
    > server
    > to light up all interfaces, however Socket.bind() fails on virtual IP
    > addresses, so I need detect and filter them out.
    >
    > Thanks.
    > Joseph
     
    Joseph Dionne, Dec 5, 2005
    #4
  5. On Mon, 05 Dec 2005 21:50:29 GMT, Joseph Dionne wrote:
    > It is my assumption that I cannot bind to a virtual "interface," and
    > I could be wrong. However, since the only "error" is a connection
    > timeout, that does not provide any useful information to detect
    > virtual IP addresses.


    A network interface as seen by the application - virtual or otherwise
    - is nothing but a data structure in the kernel, regardless of whether
    there is an underlying physical interface. If it were not possible to
    bind a Socket to them they would be of little use to anyone, since
    binding is an inherent part of every Socket connection (even though
    it's usually implicit on the client side).

    There is AFAIK no way for an application to detect with certainty
    whether a given interface is virtual or not, even from C. Use a
    heuristic instead, for example the vmware interfaces are usually
    called vmnet0 etc.

    It sounds to me like your problem is one of routing, i.e. "you can't
    get there from here". When you bind your Socket to one of the virtual
    interfaces it can't reach the destination you're trying to connect to.
    Have a look at your routing table, and try using ethereal to see what
    actual traffic is generated.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Dec 6, 2005
    #5
    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. Derek Simmons
    Replies:
    0
    Views:
    826
    Derek Simmons
    Aug 1, 2004
  2. Jéjé
    Replies:
    2
    Views:
    411
    Jéjé
    Nov 30, 2005
  3. News Admin
    Replies:
    5
    Views:
    429
    David Abrahams
    Aug 4, 2004
  4. Imre
    Replies:
    1
    Views:
    272
    Gernot Frisch
    Mar 27, 2006
  5. namespace1
    Replies:
    3
    Views:
    946
Loading...

Share This Page