开发者

Is there a way to get a WAN IP address from a phone based on its phone number?

I would like to connect two phones together for somewhat of a P2P style connection and naturally to do so, I need the phones to be able to communicate their IP addresses to each other. I've been playing around with a lot of ideas on how to do this and one thing I realized is that a phone number is a unique identifier for a phone and thus I was wondering if it could be used to get IP addresses.

I think I could transmit certain messages over SMS that would be encrypted, look god-awful, and then 开发者_运维百科get deleted, but that would be a bit of a hack and a terribly messy way to do things. I'm still mostly planning for this area of my project and would be open to suggestions.

Any help would be appreciated, thank you ahead of time! :0)


You could use a dynamic DNS service, using the phone number as the hostname. In other words, you would simply do a DNS lookup of e.g. 4255551212.dyndns.com and you'd get the last known IP address of the given phone number.

The dynamic DNS service was invented to let people on dial-up (or with frequently-changing IP addresses) run servers on their computers with host names that did not change. The way it works is, there's a client on the computer that periodically reports its IP address to a server, which puts it in a zone file on a DNS server under the specified host name. The DNS record has a short time-to-live (e.g. a minute) so that stale address information is not cached.

There's a dynamic DNS client for Android, look for DynDNS in the market and try it out.

You could run your own dynamic DNS server or use an existing one (there are many, some free). If you do do this, I would suggest running your own; then you could include some kind of authentication to prevent the privacy issue I mention in a comment.


A problem you will find is that 3G/cell connectivity gives no IP address. Also, if your phone is behind a router, you would have to port-forward on the router to get a P2P connection (without a central server being involved).

That said, if you want the external IP address, it seems that hitting http://www.whatsmyip.org/ is the best way to go.

Note: I do not know much about the dynamic DNS option suggested by kindall.


I am pretty sure you cannot directly do so. I think you need both phones to transfer phonenumber and IP to your own server and tie everything together through there. Privacy issues will creep up whatever solution you choose though, when phonenumber is involved.

Also I don't know whether you actually can connect from phone A to B directly even IF you have the IP number? But I am not an App Dev yet, so you probably know better if you can set up an end-point / open socket like thing at phone B.


you can use a site like www.whatsmyip.org to get you ip address

it is possible that your phone shares its ip address with other clients

you could also use a vpn or depending on your application a mediator server using soup or xmpp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜