PHP - 获取网关/路由器 IP、UPnP

发布于 2024-08-22 22:13:58 字数 290 浏览 8 评论 0原文

如果可能的话,我正在尝试在内部 PHP 服务器上创建 UPnP 方法。我需要它基本上与平台无关,以便它可以在 Windows、OSX 或 Linux 上运行。

我相信我可以让 SOAP 协议适用于 UPnP,但首先我必须确定服务器经过的网关/路由器的 IP 地址。是否可以使用 PHP 检索此信息?如果没有,Python 或 Ruby 怎么样?

我已经在 C# 中完成了此操作,但现在正在寻找一种更独立于平台的方法。

谢谢!

澄清:我正在寻找网关的内部 IP 地址,而不是外部 IP。

I am attempting to create a UPnP method on an internal PHP server if at all possible. I need it to be mostly platform independent so that it may run on Windows, OSX, or Linux.

I believe I can get my SOAP protocols working for UPnP, but first I must determine the IP address of the gateway/router that the server goes through. Is it possible to retrieve this information with PHP? If not, what about Python or Ruby?

I have done this in C# but am looking for a more platform independent method now.

Thanks!

CLARIFICATION: I am looking for the internal IP address of the gateway, not the external IP.

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

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

发布评论

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

评论(1

难以启齿的温柔 2024-08-29 22:13:58

您可以使用外部服务(例如whatismyip.com 和类似服务(通过cURL)检索它)。

另一种选择:由于大多数路由器允许 telnet 连接或具有 Web 管理界面,因此您可以使用 PHP 登录并获取外部 IP。

You could retrieve it using external services such as whatismyip.com and similar (via cURL).

another option: since most routers allow for telnet connection or have web admin interface, you could login using PHP and just scrape the external IP.

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