Z
zach.bastick
Hello
I am writing an application that needs to use the actual IP of a local
machine. I have tried multiple methods of finding the IP, but it seems
that each method simply returns an IP of a network interface, which is
not always the internet ip of the computer.
InetAddress in = InetAddress.getLocalHost();
InetAddress[] all = InetAddress.getAllByName(in.getHostName());
for (int i=0; i<all.length; i++) {
System.out.println(" address = " + all);
}
The output of the following code on my machine is:
address = blue-monster/192.168.0.244
address = blue-monster/10.0.3.71
...None of these are internet addresses. How do I find my internet IP?
Thanks a lot
Zach
P.S. info about my connection:
I am connected to the internet through a local network. Another
computer on the network (specifically 10.0.3.251) is my gateway. I can
get an internet ip by viewing whatismyip.com.
I am writing an application that needs to use the actual IP of a local
machine. I have tried multiple methods of finding the IP, but it seems
that each method simply returns an IP of a network interface, which is
not always the internet ip of the computer.
InetAddress in = InetAddress.getLocalHost();
InetAddress[] all = InetAddress.getAllByName(in.getHostName());
for (int i=0; i<all.length; i++) {
System.out.println(" address = " + all);
}
The output of the following code on my machine is:
address = blue-monster/192.168.0.244
address = blue-monster/10.0.3.71
...None of these are internet addresses. How do I find my internet IP?
Thanks a lot
Zach
P.S. info about my connection:
I am connected to the internet through a local network. Another
computer on the network (specifically 10.0.3.251) is my gateway. I can
get an internet ip by viewing whatismyip.com.