查询云服务器公网出口IP地址命令汇总
本篇汇总使用命令查询云服务器公网出口IP地址的方法，快速输出公网IP地址，通常应用在ddns等shell脚本中。dig 命令前提: 已经安装dig#Google dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}' #Cloudflare dig whoami.cloudflare ch txt @1.1.1.1 +short # Akamai dig whoami.akamai.net. @ns1-1.akamaitech.net. +short OpenDNS dig @resolver4.opendns.com myip.opendns.com +short dig @resolver4.opendns.com myip.opendns.com +short -4 dig @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6 curl 命令curl ip.sb curl ipinfo.io curl ifconfig.co curl icanhazip.com curl checkip.amazonaws.com curl whatismyip.akamai.com curl wgetip.com curl ip.tyk.nu curl ifconfig.me curl checkip.dyndns.org curl ipinfo.io/ip curl ipecho.net/plain curl www.trackip.net/i curl bot.whatismyipaddress.com curl 4.ifcfg.me curl ident.me curl v4.ident.me curl v6.ident.me host 命令获取公共IP会附带其他信息host myip.opendns.com resolver1.opendns.com wget 命令wget -qO- icanhazip.com wget -qO- ipecho.net/plain; echo nc 命令nc 4.ifcfg.me 23 | grep IPv4 | cut -d' ' -f4 ftp 命令echo close | ftp 4.ifcfg.me | awk '{print $4; exit}' lynx 命令前提: 已经安装lynxlynx -dump checkip.dyndns.org 最常见的是curl和dig，选择适合自己的就好，希望以上内容能够对您有所帮助~参考文献：https://askubuntu.com/questions/95910/command-for-determining-my-public-iphttps://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-a-shell-script