有没有 linux 命令可以获取我的公网 ip, 类似 ip138.com 上获取的 ip?

2014-07-03 16:30:05 +08:00
 Akagi201
9982 次点击
所在节点    问与答
13 条回复
Livid
2014-07-03 16:31:38 +08:00
20150517
2014-07-03 16:32:49 +08:00
kingwkb
2014-07-03 16:35:27 +08:00
给你个国内 速度超快的版本

curl 115.29.200.26
sud0wiz
2014-07-03 17:13:05 +08:00
国内我用 curl ip.cn
Tink
2014-07-03 17:14:21 +08:00
Tonni
2014-07-03 17:16:42 +08:00
curl http://ipecho.net/plain; echo

这个,上面发的连HTML源码都输出了
kfll
2014-07-03 17:26:37 +08:00
dig +short myip.opendns.com @208.67.222.222 @208.67.220.220

UDP的
panzhc
2014-07-03 17:34:09 +08:00
zhujinliang
2014-07-03 18:00:16 +08:00
以前写了一个,就是curl ip138页面里面嵌的那个iframe,然后grep一下
不过刚才再去看,ip138变聪明了,嵌的那个iframe src会变了
fclql
2014-07-03 18:25:28 +08:00
参照op的ddns脚本
Havee
2014-07-03 20:15:50 +08:00
试试这个脚本

URL=ip.cn

help() {
echo -e "
myip # get your ip
myip ipadress # get your adress from ip
myip -h # display this help message\n"
}

if [[ "$1" == "-h" || "$1" == "--help" ]]; then
help
exit 0
elif [ -z "$1" ]; then
curl $URL
else
curl ${URL}/index.php?ip=$1
fi
yangg
2014-07-03 22:28:04 +08:00
@sud0wiz 这个挺快的,有只返回IP的地址么
likebeta
2015-09-05 20:21:53 +08:00
补充一个`curl ns1.dnspod.net:6666`

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/120808

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX