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

查看:50
本文介绍了以编程方式发现公共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?

P.S.我正在计划编写一个简短的python脚本来实现它

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

推荐答案

编辑: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天全站免登陆