下面几个链接都可以帮助我们获取到本机的外网IP,但是返回值稍有不同,有的返回纯净的IP(结尾有带换行的和不带换行的),有的携带一些其他内容,有的支持http和https,有的支持http或https,这里面ip.cn最TMD有意思,我在Mac上访问,返回HTML,在Linux上访问,返回JSON.
curl http://whatismyip.akamai.com
curl http[s]://icanhazip.com
curl http[s]://ifconfig.me #国内不稳定,不建议使用
curl http[s]://myip.dnsomatic.com
curl https://ip.cn
curl http[s]://cip.cc
curl http[s]://myip.ipip.net
curl http://ip.d3vm.net