I looked for some code that will help me to get the ip that the iPhone connect with.
I find this one:
- (NSString *)getIPAddress { NSString *addr
Have a look at the example in my second Answer here.
In a nutshell it uses *http://www.dyndns.org/cgi-bin/check_ip.cg*i to get the extenal I.P