如何获取自己的公网IP呢?

1. dig查google dns

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
#或
dig +short myip.opendns.com @resolver1.opendns.com

2. curl查IP网站


curl icanhazip.com
curl ifconfig.me
curl icanhazip.com
curl ipecho.net/plain
curl ifconfig.co

3. 参考

http://www.chenshake.com/page/2/ https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/