[ Linux ] 获取本机公网 IP

https://www.cnblogs.com/yeungchie/

给出两种方式获取本机的公网 IP 地址,方便在脚本中使用。

curl

curl ipinfo.io/ip 2>/dev/null

更多可用的地址:

https://checkip.amazonaws.com
https://api.ipify.org
https://ifconfig.me/ip
https://icanhazip.com
https://ipinfo.io/ip
https://ipecho.net/plain
https://checkipv4.dedyn.io

dig

dig +short myip.opendns.com @resolver1.opendns.com 2>/dev/null
posted @ 2023-05-21 20:39  YEUNGCHIE  阅读(203)  评论(0编辑  收藏  举报