# 2021-01-07 #「Linux」- 如何确定公网网络地址?
使用第三方站点
curl "http://ifconfig.me" curl "http://icanhazip.com" curl "http://ipecho.net/plain" curl "http://ifconfig.co" ################################################################################ curl checkip.amazonaws.com curl ifconfig.me curl icanhazip.com curl ipecho.net/plain curl ifconfig.co ## store output in $server_ip ## server_ip="$(curl ifconfig.co)" ## Display it ## printf "Server public ip4 %s\n" $server_ip
命令行获取(推荐)
dig +short myip.opendns.com @resolver1.opendns.com dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
参考文献
K4NZ/如何确定公网网络地址?
How To Find My Public IP Address From Command Line On a Linux
How To Find My Public IP Address From Command Line On a Linux - nixCraft