views:

190

answers:

2

Hi!

i'm developing a java application using the jstun library (hxxp://jstun.javawi.de/), and i need to compare my public ip with the one chosen by the kernel (wildcard address - hxxp://java.sun.com/j2se/1.5.0/docs/api/java/net/DatagramSocket.html#DatagramSocket() ) when i create a udp socket.

what i don't understand is, if my local ip on my natted network is in the form of 192.168.1.x, why do i get an ip such as 10.x.x.x ?

is there a particular reason why the two are totally unrelated? if i wasn't behind a nat, would the kernel bind the socket to my public address?

thanks a lot! asymmetric

+1  A: 

For a sending socket the source IP would be determined by the host routing table according to the destination IP; for receiving socket the destination IP is what you get. The "public" IP your peers see is the source address on the packet from you, which is re-written by NAT to be whatever internal addresses are translated to.

Nikolai N Fetissov
A: 

i failed to mention a rather important thing: i'm developing for android, and running my code on the android emulator, which explains the 10.x.x.x address thing..

i should dig deeper into that.. thanks for the help!

for those that are interested: hxxp://developer.android.com/guide/developing/tools/emulator.html#networkaddresses

asymmetric