有没有办法根据电话号码从电话获取 WAN IP 地址?

发布于 2024-11-15 10:07:05 字数 247 浏览 2 评论 0原文

我想将两部电话连接在一起以进行某种 P2P 风格的连接,自然地,我需要电话能够相互传达其 IP 地址。我一直在思考如何做到这一点,我意识到的一件事是电话号码是电话的唯一标识符,因此我想知道它是否可以用于获取 IP 地址。

我想我可以通过短信传输某些消息,这些消息会被加密,看起来很糟糕,然后被删除,但这会有点黑客行为,而且是一种非常混乱的做事方式。我仍然主要为我的项目的这个领域进行规划,并且愿意接受建议。

任何帮助将不胜感激,提前谢谢您! :0)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浮云落日 2024-11-22 10:07:05

您可以使用动态 DNS 服务,将电话号码用作主机名。换句话说,您只需进行 DNS 查找(例如 4255551212.dyndns.com),即可获得给定电话号码的最后一个已知 IP 地址。

动态 DNS 服务的发明是为了让拨号(或 IP 地址经常更改)的人们在其计算机上运行主机名不变的服务器。它的工作方式是,计算机上有一个客户端定期向服务器报告其 IP 地址,服务器将其放入 DNS 服务器上指定主机名下的区域文件中。 DNS记录的生存时间很短(例如一分钟),因此过时的地址信息不会被缓存。

Android 有一个动态 DNS 客户端,请在市场上寻找 DynDNS 并尝试一下。

您可以运行自己的动态 DNS 服务器或使用现有的服务器(有很多,其中一些是免费的)。如果您这样做,我建议您自己运行;那么您可以包含某种身份验证来防止我在评论中提到的隐私问题。

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.

枕头说它不想醒 2024-11-22 10:07:05

您会发现的一个问题是 3G/蜂窝连接不提供 IP 地址。此外,如果您的手机位于路由器后面,则必须在路由器上进行端口转发才能获得 P2P 连接(不涉及中央服务器)。

也就是说,如果您想要外部 IP 地址,似乎需要点击 http://www.whatsmyip.org/ 是最好的方法。

注意:我对 kindall 建议的动态 DNS 选项不太了解。

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.

哀由 2024-11-22 10:07:05

我很确定你不能直接这样做。我认为您需要两部电话将电话号码和 IP 传输到您自己的服务器,并通过那里将所有内容绑定在一起。当涉及电话号码时,无论您选择什么解决方案,隐私问题都会逐渐出现。

另外我不知道即使你有IP号码,是否真的可以从手机A直接连接到B?但我还不是应用程序开发人员,所以如果您可以在电话 B 上设置一个端点/开放套接字之类的东西,您可能会更清楚。

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.

粉红×色少女 2024-11-22 10:07:05

您可以使用像 www.whatsmyip.org 这样的网站来获取您的 IP 地址

您的手机可能与其他客户端共享其 IP 地址

您也可以使用 VPN,或者根据您的应用程序使用 soup 或 xmpp 的中介服务器

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文