以编程方式发现公共 IP [英] Discovering public IP programmatically

查看:24
本文介绍了以编程方式发现公共 IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在路由器后面,我需要一个简单的命令来发现我的公共 ip(而不是在谷歌上搜索我的 ip 并单击结果)

I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)

是否有任何标准协议?我听说过 STUN,但我不知道如何使用它?

Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it?

附言我打算写一个简短的 python 脚本来做到这一点

P.S. I'm planning on writing a short python script to do it

推荐答案

EDIT:curlmyip.com 不再可用.(感谢maxywb)

EDIT: curlmyip.com is no longer available. (thanks maxywb)

原帖:

在撰写本文时,curlmyip.com 有效.从命令行:

As of writing this post, curlmyip.com works. From the command line:

curl curlmyip.com

这是一个第三方网站,可能会在几年后可用,也可能不会可用.但就目前而言,这似乎非常简单且切中要害.

It's a third-party website, which may or may not be available a couple years down the road. But for the time being, it seems pretty simple and to the point.

这篇关于以编程方式发现公共 IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆