Link to home
Start Free TrialLog in
Avatar of s_lavie
s_lavie

asked on

Detecting multiple IPs

I have a machine with 3 active ip addresses defined on it.
There is only one network card on that machine - does it matter?

I tried to discovered all three by using:

InetAddress[] hosts = InetAddress.getAllByName(InetAddress.getLocalHost().getHostAddress());

Nevertheless, hosts.length == 1

Why?
Avatar of Exceter
Exceter
Flag of United States of America image

Out of curiousity, how can you simultaneously have three active IP adresses on the same network card?
Avatar of Mick Barry
And what is the address it's returning?
Avatar of s_lavie
s_lavie

ASKER

> Out of curiousity, how can you simultaneously have three active IP adresses on the same network card?
You just add IP address (at least on win2000 it works...)
> And what is the address it's returning?
The first IP it finds.

Anyway I managed to get all IPs by using:
InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());

Thanks anyway....
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial